author | Claus Gittinger <cg@exept.de> |
Fri, 15 Jun 2018 10:54:35 +0200 | |
changeset 5816 | 7876c07931a7 |
parent 5758 | bff79a5aad10 |
child 5855 | 0a054286d062 |
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 |
" |
|
1752 | 12 |
"{ Package: 'stx:libwidg2' }" |
13 |
||
4703 | 14 |
"{ NameSpace: Smalltalk }" |
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 |
3728 | 20 |
hasConstantHeight constantHeight previousExtent listRenderer |
4858 | 21 |
cachedPreferredExtent activeScrollProcess' |
1390 | 22 |
classVariableNames:'DefaultForegroundColor DefaultBackgroundColor DefaultShadowColor |
23 |
DefaultLightColor StopRedrawSignal' |
|
24 |
poolDictionaries:'' |
|
1430 | 25 |
category:'Views-Lists' |
1390 | 26 |
! |
27 |
||
2352 | 28 |
Object subclass:#Renderer |
29 |
instanceVariableNames:'view' |
|
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
32 |
privateIn:ListModelView |
|
33 |
! |
|
34 |
||
3717 | 35 |
ListModelView::Renderer subclass:#TableRenderer |
36 |
instanceVariableNames:'xSplitbars hasFixedItemWidth savedCursor dragCursor |
|
37 |
columnDescriptors separatorOneDColor receiver dragOperation |
|
38 |
requiredColumnHeight minimumRequiredColumnHeight attributes' |
|
39 |
classVariableNames:'' |
|
40 |
poolDictionaries:'' |
|
41 |
privateIn:ListModelView |
|
42 |
! |
|
43 |
||
44 |
Object subclass:#ColumnDescriptor |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
45 |
instanceVariableNames:'dataSetColumnSpec columnNumber width' |
3717 | 46 |
classVariableNames:'ClipColumnQuerySignal' |
47 |
poolDictionaries:'' |
|
48 |
privateIn:ListModelView::TableRenderer |
|
49 |
! |
|
50 |
||
1390 | 51 |
!ListModelView class methodsFor:'documentation'! |
52 |
||
1431 | 53 |
copyright |
54 |
" |
|
55 |
COPYRIGHT (c) 1999 by eXept Software AG |
|
2265 | 56 |
All Rights Reserved |
1431 | 57 |
|
58 |
This software is furnished under a license and may be used |
|
59 |
only in accordance with the terms of that license and with the |
|
60 |
inclusion of the above copyright notice. This software may not |
|
61 |
be provided or otherwise made available to, or used by, any |
|
62 |
other person. No title to or ownership of the software is |
|
63 |
hereby transferred. |
|
64 |
" |
|
65 |
||
66 |
! |
|
67 |
||
1390 | 68 |
documentation |
69 |
" |
|
1431 | 70 |
This widget is a new improved revision of the good-old ListView. |
71 |
In contrast to ListView, this one reacts on changes of the |
|
3386 | 72 |
underlying list and performs optimized redraws. |
73 |
It requires a List (or alike) as list. |
|
1431 | 74 |
|
1390 | 75 |
This class can only passively display collections of elements. |
76 |
The class doesn't keep its own list, it works directly on |
|
3386 | 77 |
the list ( List or HierarchicalList ). |
78 |
||
3390 | 79 |
ATTENTION (warning by cg): |
3728 | 80 |
in contrast to its inappropriate name, this class COMPLETELY ignores the model |
81 |
instance variable - all is through the list/listHolder. |
|
3390 | 82 |
|
1390 | 83 |
Each list item is obligated to provide 3 services: |
3728 | 84 |
- heightOn:aGC |
85 |
- widthOn:aGC |
|
86 |
- displayOn:aGC x:x y:y |
|
1390 | 87 |
|
88 |
[Instance variables:] |
|
3728 | 89 |
list <List-Model> List or HierarchicalList ... |
90 |
listHolder <Model> Model, which keeps a List |
|
91 |
textStartLeft <Number> left inset of text |
|
92 |
viewOrigin <Point> the current origin |
|
93 |
enabled <Boolean> widget is enabled/disabeled |
|
94 |
fgColor <Color> color to draw characters |
|
95 |
bgColor <Color> the background |
|
96 |
lineSpacing <Number> pixels between lines |
|
97 |
widthOfContents <Number> cached width of widest line |
|
98 |
computeWidthInRange <Point> used for recompute width of contents |
|
99 |
startOfLinesY <Collection> keeps all the absolute Y-start positions |
|
100 |
for each line in the list. The first |
|
101 |
entry into the list is the top Y inset. |
|
102 |
supportsDisplayInRange <Boolean> set to true if the list elements |
|
103 |
supports the service: |
|
104 |
#displayOn:x:y:h: |
|
105 |
||
106 |
hasConstantHeight <Boolean> true, than each line has the same height |
|
107 |
||
108 |
constantHeight <SmallInteger> hasConstantHeight is turned on, this |
|
109 |
is the used line height |
|
2264 | 110 |
|
1390 | 111 |
[author:] |
3728 | 112 |
Claus Atzkern |
1390 | 113 |
|
114 |
[see also:] |
|
115 |
||
3728 | 116 |
SelectionInListModelView |
117 |
HierarchicalListView |
|
118 |
List |
|
119 |
HierarchicalList |
|
1390 | 120 |
" |
121 |
! |
|
122 |
||
123 |
examples |
|
124 |
" |
|
2265 | 125 |
[exBegin] |
1390 | 126 |
|top list view up index| |
127 |
||
128 |
list := List new. |
|
129 |
||
130 |
top := StandardSystemView new; extent:300@300. |
|
131 |
view := ScrollableView for:ListModelView miniScroller:true |
|
2265 | 132 |
origin:0.0@0.0 corner:1.0@1.0 in:top. |
1827 | 133 |
|
1390 | 134 |
view list:list. |
135 |
top openAndWait. |
|
136 |
up := true. |
|
137 |
||
138 |
[top shown] whileTrue:[ |
|
2265 | 139 |
Delay waitForSeconds:0.2. |
1390 | 140 |
|
2265 | 141 |
up ifTrue:[ |
142 |
index := 1 + (list size). |
|
143 |
list add:('element: ', index printString). |
|
144 |
up := index < 20 |
|
145 |
] ifFalse:[ |
|
146 |
list removeIndex:1. |
|
147 |
up := list isEmpty. |
|
148 |
] |
|
1390 | 149 |
]. |
2265 | 150 |
[exEnd] |
1390 | 151 |
|
152 |
" |
|
153 |
||
154 |
! ! |
|
155 |
||
156 |
!ListModelView class methodsFor:'initialization'! |
|
157 |
||
158 |
initialize |
|
1409 | 159 |
"setup the signals |
160 |
" |
|
4911 | 161 |
StopRedrawSignal isNil ifTrue:[ |
162 |
StopRedrawSignal := Notification newSignalMayProceed:true. |
|
163 |
StopRedrawSignal nameClass:self message:#stopRedrawSignal. |
|
164 |
]. |
|
1390 | 165 |
! ! |
166 |
||
167 |
!ListModelView class methodsFor:'Signal constants'! |
|
168 |
||
169 |
stopRedrawSignal |
|
170 |
^ StopRedrawSignal |
|
171 |
! ! |
|
172 |
||
173 |
!ListModelView class methodsFor:'defaults'! |
|
174 |
||
2352 | 175 |
defaultRenderer |
176 |
^ Renderer |
|
177 |
! |
|
178 |
||
1390 | 179 |
updateStyleCache |
180 |
"extract values from the styleSheet and cache them in class variables" |
|
181 |
||
182 |
<resource: #style ( |
|
3926 | 183 |
#'text.backgroundColor' #'text.foregroundColor' |
184 |
#'selection.shadowColor' #'selection.lightColor' |
|
185 |
#'text.font' |
|
186 |
)> |
|
1390 | 187 |
|
4513 | 188 |
DefaultForegroundColor := StyleSheet colorAt:'text.foregroundColor' default:Color black. |
1390 | 189 |
DefaultBackgroundColor := StyleSheet colorAt:'text.backgroundColor'. |
190 |
DefaultShadowColor := StyleSheet colorAt:'selection.shadowColor'. |
|
191 |
DefaultLightColor := StyleSheet colorAt:'selection.lightColor'. |
|
3926 | 192 |
"/ DefaultFont := StyleSheet fontAt:'text.font'. |
1390 | 193 |
|
194 |
" |
|
195 |
self updateStyleCache |
|
196 |
" |
|
197 |
||
3926 | 198 |
"Modified: / 14-08-2010 / 12:23:35 / cg" |
1390 | 199 |
! ! |
200 |
||
201 |
!ListModelView methodsFor:'accessing'! |
|
202 |
||
203 |
list |
|
204 |
"get the list of items |
|
205 |
" |
|
206 |
^ list |
|
207 |
||
208 |
||
209 |
! |
|
210 |
||
211 |
list:aList |
|
212 |
"set the list of items |
|
213 |
" |
|
2264 | 214 |
|negatedOrg| |
1443 | 215 |
|
3728 | 216 |
listRenderer listWillChange. |
2640 | 217 |
|
1452 | 218 |
list ~~ aList ifTrue:[ |
3891 | 219 |
list removeDependent:self. |
220 |
list := aList. |
|
221 |
list isNil ifTrue:[list := self newDefaultList ]. |
|
222 |
list addDependent:self |
|
1452 | 223 |
]. |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
224 |
"/ preferredExtent := nil. |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
225 |
cachedPreferredExtent := nil. |
2264 | 226 |
widthOfContents := nil. |
227 |
||
3891 | 228 |
self recomputeHeightOfContents. |
229 |
||
230 |
scrollWhenUpdating == #beginOfText ifTrue:[ |
|
231 |
viewOrigin = (0@0) ifFalse:[ |
|
232 |
self originWillChange. |
|
233 |
negatedOrg := viewOrigin negated. |
|
234 |
viewOrigin := (0@0). |
|
235 |
self originChanged:negatedOrg. |
|
236 |
]. |
|
237 |
] ifFalse:[ |
|
238 |
scrollWhenUpdating == #endOfText ifTrue:[ |
|
239 |
self scrollTo:(0 @ self heightOfContents - self innerHeight) redraw:false |
|
240 |
] |
|
1422 | 241 |
]. |
3891 | 242 |
self invalidate. |
1457 | 243 |
self contentsChanged |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
244 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
245 |
|
3728 | 246 |
listRenderer |
247 |
"returns the used listrenderer |
|
248 |
" |
|
249 |
^ listRenderer |
|
250 |
! |
|
251 |
||
252 |
listRenderer:aRendererOrRendererClass |
|
253 |
"change the used listRenderer |
|
2644 | 254 |
" |
3728 | 255 |
aRendererOrRendererClass isNil ifTrue:[^ self]. |
256 |
||
257 |
listRenderer == aRendererOrRendererClass ifTrue:[^ self]. |
|
258 |
listRenderer notNil ifTrue:[listRenderer release]. |
|
259 |
||
260 |
aRendererOrRendererClass isBehavior ifTrue:[ |
|
261 |
listRenderer := aRendererOrRendererClass basicNew initialize. |
|
262 |
] ifFalse:[ |
|
263 |
listRenderer := aRendererOrRendererClass. |
|
2644 | 264 |
]. |
3728 | 265 |
listRenderer forView:self. |
266 |
! |
|
267 |
||
3891 | 268 |
renderer |
4243 | 269 |
<resource: #obsolete> |
3891 | 270 |
self obsoleteMethodWarning:'naming conflict renderer vs. listRenderer'. |
271 |
^ self listRenderer |
|
272 |
! |
|
273 |
||
3728 | 274 |
renderer:aTableRenderer |
4243 | 275 |
<resource: #obsolete> |
3728 | 276 |
self obsoleteMethodWarning:'naming conflict renderer vs. listRenderer'. |
277 |
self listRenderer:aTableRenderer |
|
3717 | 278 |
! |
279 |
||
280 |
setupTableRenderer |
|
3728 | 281 |
"creates a renderer with columns based on a DataSetColumnSpec |
3717 | 282 |
answer the new renderer" |
283 |
||
3728 | 284 |
self listRenderer:TableRenderer. |
285 |
^ listRenderer |
|
1390 | 286 |
! ! |
287 |
||
1818 | 288 |
!ListModelView methodsFor:'accessing-behavior'! |
1390 | 289 |
|
1748 | 290 |
autoScroll |
291 |
"returns true if auto scrolling is enabled |
|
292 |
" |
|
293 |
^ autoScroll |
|
294 |
! |
|
295 |
||
296 |
autoScroll:aBool |
|
297 |
"returns true if auto scrolling is enabled |
|
298 |
" |
|
299 |
autoScroll := aBool ? true. |
|
300 |
! |
|
301 |
||
1390 | 302 |
enabled |
303 |
"returns the enabled state |
|
304 |
" |
|
305 |
^ enabled |
|
306 |
||
307 |
||
308 |
! |
|
309 |
||
310 |
enabled:aBoolean |
|
311 |
"set the enabled state |
|
312 |
" |
|
313 |
enabled := aBoolean |
|
314 |
||
315 |
||
1742 | 316 |
! |
317 |
||
2261 | 318 |
hasConstantHeight |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
319 |
"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
|
320 |
Optimizes scroll and redraw operations |
2261 | 321 |
" |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
322 |
|
2261 | 323 |
^ hasConstantHeight |
324 |
! |
|
325 |
||
326 |
hasConstantHeight:aBool |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
327 |
"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
|
328 |
Optimizes scrolling and redraw. |
2261 | 329 |
" |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
330 |
|
2261 | 331 |
aBool == hasConstantHeight ifTrue:[ |
3728 | 332 |
^ self |
2261 | 333 |
]. |
2264 | 334 |
constantHeight := nil. |
2261 | 335 |
hasConstantHeight := aBool. |
336 |
||
337 |
self lostSynchronisation. |
|
338 |
! |
|
339 |
||
1742 | 340 |
scrollWhenUpdating:aSymbolOrNil |
3728 | 341 |
"define how to scroll, when I get a new text |
1742 | 342 |
(via the model or the #contents/#list) |
343 |
Allowed arguments are: |
|
2265 | 344 |
#keep / nil -> no change |
345 |
#endOfText -> scroll to the end |
|
346 |
#beginOfText -> scroll to the top |
|
1742 | 347 |
The default is #beginOfText. |
348 |
This may be useful for fields which get new values assigned from |
|
349 |
the program (i.e. not from the user) |
|
350 |
" |
|
351 |
||
1827 | 352 |
scrollWhenUpdating := aSymbolOrNil |
1742 | 353 |
|
354 |
||
1390 | 355 |
! ! |
356 |
||
1818 | 357 |
!ListModelView methodsFor:'accessing-items'! |
1390 | 358 |
|
359 |
at:anIndex |
|
360 |
"return the list element at an index |
|
361 |
" |
|
362 |
^ list at:anIndex |
|
363 |
! |
|
364 |
||
365 |
at:anIndex ifAbsent:exceptionBlock |
|
3728 | 366 |
"return the list element at an index if valid. |
367 |
If the index is invalid, return the result of evaluating |
|
1390 | 368 |
the exceptionblock. |
369 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
370 |
^ list at:anIndex ifAbsent:exceptionBlock |
2408 | 371 |
! |
372 |
||
373 |
findLast:aOneArgBlock |
|
374 |
"find the last list entry, for which evaluation of the argument, aOneArgBlock |
|
375 |
returns true; return its index or 0 if none detected. |
|
376 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
377 |
^ list findLast:aOneArgBlock |
1390 | 378 |
! |
379 |
||
380 |
identityIndexOf:anElement |
|
381 |
"returns the index of an element or nil |
|
382 |
" |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
383 |
^ list identityIndexOf:anElement |
2408 | 384 |
! |
1390 | 385 |
|
2408 | 386 |
last |
387 |
"returns the last list entry |
|
388 |
" |
|
389 |
^ list last |
|
1390 | 390 |
! ! |
391 |
||
1818 | 392 |
!ListModelView methodsFor:'accessing-look'! |
1390 | 393 |
|
394 |
backgroundColor |
|
395 |
"get the background color |
|
396 |
" |
|
397 |
^ bgColor |
|
398 |
||
399 |
||
400 |
! |
|
401 |
||
402 |
font:aFont |
|
403 |
"set a new font |
|
404 |
" |
|
4500 | 405 |
|oldWidth oldHeight newFont| |
406 |
||
407 |
(aFont isNil or:[aFont = gc font]) ifFalse:[ |
|
408 |
oldWidth := gc font width. |
|
409 |
oldHeight := gc font height. |
|
410 |
||
411 |
super font:aFont. |
|
5206 | 412 |
newFont := gc deviceFont. |
4500 | 413 |
|
414 |
newFont width ~~ oldWidth ifTrue:[ "/ force a recomputation |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
415 |
"/ preferredExtent := nil. |
4500 | 416 |
cachedPreferredExtent := nil. |
417 |
widthOfContents := nil. |
|
418 |
]. |
|
419 |
realized ifTrue:[ |
|
420 |
oldHeight ~~ newFont height ifTrue:[ |
|
421 |
self recomputeHeightOfContents. |
|
422 |
self contentsChanged. |
|
423 |
]. |
|
424 |
self invalidate |
|
425 |
]. |
|
1390 | 426 |
]. |
427 |
! |
|
428 |
||
429 |
foregroundColor |
|
430 |
"get the foreground color |
|
431 |
" |
|
432 |
^ fgColor |
|
433 |
||
434 |
! |
|
435 |
||
436 |
foregroundColor:aColor |
|
437 |
"set the foreground color |
|
438 |
" |
|
439 |
(aColor notNil and:[fgColor ~~ aColor]) ifTrue:[ |
|
4509 | 440 |
self realized ifTrue:[ |
5000 | 441 |
fgColor := aColor onDevice:device. |
4509 | 442 |
self invalidate |
443 |
] ifFalse:[ |
|
444 |
fgColor := aColor |
|
445 |
] |
|
1390 | 446 |
] |
1945 | 447 |
! |
448 |
||
449 |
lineSpacing |
|
5256 | 450 |
"get the lineSpacing - that's an additional number of pixels, |
1945 | 451 |
by which lines are vertically separated. |
452 |
" |
|
453 |
^ lineSpacing |
|
454 |
! |
|
455 |
||
456 |
lineSpacing:aNumber |
|
5256 | 457 |
"set the lineSpacing - that's an additional number of pixels, |
1945 | 458 |
by which lines are vertically separated. |
459 |
" |
|
460 |
lineSpacing ~= aNumber ifTrue:[ |
|
5256 | 461 |
lineSpacing := aNumber. |
462 |
||
463 |
realized ifTrue:[ |
|
464 |
self recomputeHeightOfContents. |
|
465 |
self invalidate |
|
466 |
]. |
|
467 |
self contentsChanged. |
|
1945 | 468 |
] |
2605
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
469 |
! |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
470 |
|
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
471 |
viewBackground:aColor |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
472 |
"set the background color |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
473 |
" |
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
474 |
(aColor notNil and:[bgColor ~~ aColor]) ifTrue:[ |
4509 | 475 |
bgColor := aColor. |
476 |
super viewBackground:bgColor. |
|
477 |
||
478 |
self realized ifTrue:[ |
|
5000 | 479 |
bgColor := bgColor onDevice:device. |
4509 | 480 |
self invalidate |
481 |
]. |
|
2605
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
482 |
]. |
1390 | 483 |
! ! |
484 |
||
1818 | 485 |
!ListModelView methodsFor:'accessing-mvc'! |
1390 | 486 |
|
487 |
listHolder |
|
488 |
"returns the listHolder or nil |
|
489 |
" |
|
490 |
^ listHolder |
|
491 |
! |
|
492 |
||
493 |
listHolder:aListHolder |
|
494 |
"set a new listHolder |
|
495 |
" |
|
496 |
listHolder removeDependent:self. |
|
497 |
||
498 |
(listHolder := aListHolder) notNil ifTrue:[ |
|
2265 | 499 |
listHolder addDependent:self. |
1390 | 500 |
]. |
501 |
self list:(listHolder value). |
|
502 |
! ! |
|
503 |
||
504 |
!ListModelView methodsFor:'change & update'! |
|
505 |
||
506 |
lineChangedAt:aLnNr with:arg |
|
2548 | 507 |
"line changed at position; check whether line height changed" |
508 |
||
509 |
|cache |
|
1390 | 510 |
oldHeight "{ Class:SmallInteger }" |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
511 |
deltaHeight "{ Class:SmallInteger }" | |
2548 | 512 |
|
513 |
(arg == #icon or:[arg == #hierarchy]) ifTrue:[ |
|
3728 | 514 |
^ self |
1390 | 515 |
]. |
2264 | 516 |
hasConstantHeight ifTrue:[ |
3728 | 517 |
self invalidateLineAt:aLnNr. |
518 |
^ self |
|
2264 | 519 |
]. |
520 |
||
1390 | 521 |
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
|
522 |
deltaHeight := (self heightOfLineAt:aLnNr) - oldHeight. |
1390 | 523 |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
524 |
deltaHeight == 0 ifTrue:[ |
3728 | 525 |
self invalidateLineAt:aLnNr. |
526 |
^ self |
|
1390 | 527 |
]. |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
528 |
cache := self startOfLinesY. |
1390 | 529 |
|
2548 | 530 |
aLnNr + 1 to:cache size do:[:i| |
3728 | 531 |
cache at:i put:((cache at:i) + deltaHeight) |
532 |
]. |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
533 |
self contentsChanged. |
1390 | 534 |
self invalidate. |
535 |
! |
|
536 |
||
537 |
listChangedInsert:start nItems:nLines |
|
3894
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
538 |
"list changed; items are added" |
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
539 |
|
2385 | 540 |
|newLines |
1390 | 541 |
run "{ Class: SmallInteger }" |
1457 | 542 |
newSz "{ Class: SmallInteger }" |
1390 | 543 |
cpyHg "{ Class: SmallInteger }" |
544 |
absY0 "{ Class: SmallInteger }" |
|
545 |
absY1 "{ Class: SmallInteger }" |
|
546 |
visY0 "{ Class: SmallInteger }" |
|
547 |
visY1 "{ Class: SmallInteger }" |
|
548 |
orgY "{ Class: SmallInteger }" |
|
549 |
dltY "{ Class: SmallInteger }" |
|
550 |
maxHg "{ Class: SmallInteger }" |
|
551 |
| |
|
552 |
||
553 |
nLines == 0 ifTrue:[^ self ]. |
|
554 |
self listSizeChanged:start nLines:nLines. |
|
555 |
||
1457 | 556 |
newSz := startOfLinesY size + nLines. |
557 |
||
2408 | 558 |
(newSz - 1) ~~ self size ifTrue:[ |
3891 | 559 |
"/ |
560 |
"/ no longer synchronized |
|
561 |
"/ |
|
562 |
self lostSynchronisation. |
|
563 |
^ self |
|
1451 | 564 |
]. |
3712 | 565 |
newLines := startOfLinesY. "/ copy. |
2385 | 566 |
newLines addAll:(Array new:nLines) beforeIndex:start + 1. |
567 |
absY0 := newLines at:start. |
|
1390 | 568 |
absY1 := absY0. |
569 |
run := start. |
|
570 |
||
571 |
nLines timesRepeat:[ |
|
3891 | 572 |
absY1 := absY1 + (self heightOfLineAt:run). |
573 |
run := run + 1. |
|
574 |
newLines at:run put:absY1. |
|
1390 | 575 |
]. |
576 |
dltY := absY1 - absY0. |
|
1457 | 577 |
|
578 |
run + 1 to:newSz do:[:i||v| |
|
3891 | 579 |
newLines at:i put:((newLines at:i) + dltY) |
1390 | 580 |
]. |
2385 | 581 |
startOfLinesY := newLines. |
1390 | 582 |
|
583 |
orgY := viewOrigin y. |
|
584 |
absY1 := absY0 + dltY. |
|
585 |
visY0 := absY0 - orgY. |
|
586 |
visY1 := absY1 - orgY. |
|
587 |
maxHg := height - margin. |
|
588 |
||
589 |
absY0 < orgY ifTrue:[ |
|
3891 | 590 |
self originWillChange. |
591 |
viewOrigin y:(dltY + orgY). |
|
592 |
self originChanged:(0 @ dltY). |
|
1390 | 593 |
]. |
1457 | 594 |
|
1390 | 595 |
(visY0 >= maxHg or:[visY1 <= margin]) ifTrue:[ |
3891 | 596 |
self contentsChanged. |
597 |
^ self |
|
1390 | 598 |
]. |
599 |
visY0 := visY0 max:margin. |
|
600 |
visY1 := visY1 min:maxHg. |
|
601 |
||
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
602 |
self hasDamage ifTrue:[ |
3891 | 603 |
self invalidate:(Rectangle left:0 |
604 |
top:visY0 |
|
605 |
width:width |
|
606 |
height:height - visY0). |
|
607 |
||
608 |
self contentsChanged. |
|
609 |
^ self |
|
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
610 |
]. |
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
611 |
|
2408 | 612 |
(start == self size or:[(cpyHg := maxHg - visY1) < 20]) ifTrue:[ |
3891 | 613 |
visY1 := maxHg |
1390 | 614 |
] ifFalse:[ |
3894
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
615 |
shown ifTrue:[ |
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
616 |
self catchExpose. |
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
617 |
self copyFrom:self x:0 y:visY0 |
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
618 |
toX:0 y:visY1 |
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
619 |
width:width height:cpyHg async:true. |
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
620 |
self waitForExpose. |
6c2e84f93db1
changed: #listChangedInsert:nItems:
Stefan Vogel <sv@exept.de>
parents:
3892
diff
changeset
|
621 |
]. |
1390 | 622 |
]. |
623 |
||
1457 | 624 |
self invalidateX:margin |
3891 | 625 |
y:visY0 |
626 |
width:width - margin - margin |
|
627 |
height:(visY1 - visY0). |
|
1457 | 628 |
|
1390 | 629 |
self contentsChanged. |
630 |
! |
|
631 |
||
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
632 |
listChangedRemove:aStart toIndex:aStop |
5196 | 633 |
"list changed; items are removed" |
634 |
||
635 |
|doRedraw newLines |
|
1390 | 636 |
size "{ Class: SmallInteger }" |
637 |
absY0 "{ Class: SmallInteger }" |
|
638 |
absY1 "{ Class: SmallInteger }" |
|
639 |
visY0 "{ Class: SmallInteger }" |
|
640 |
visY1 "{ Class: SmallInteger }" |
|
641 |
orgY "{ Class: SmallInteger }" |
|
642 |
orgX "{ Class: SmallInteger }" |
|
643 |
dltY "{ Class: SmallInteger }" |
|
644 |
cpyHg "{ Class: SmallInteger }" |
|
645 |
maxHg "{ Class: SmallInteger }" |
|
1444
0b7cd00e2537
check range before delete lines
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
646 |
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
|
647 |
start "{ Class: SmallInteger }" |
1457 | 648 |
newSz "{ Class: SmallInteger }" |
1390 | 649 |
| |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
650 |
stop := aStop. |
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
651 |
start := aStart. |
1390 | 652 |
|
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
653 |
(size := stop - start + 1) == 0 ifTrue:[ |
3891 | 654 |
^ self |
1390 | 655 |
]. |
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
656 |
|
1390 | 657 |
self listSizeChanged:start nLines:(size negated). |
1451 | 658 |
|
1457 | 659 |
newSz := startOfLinesY size - size. |
660 |
||
2408 | 661 |
(newSz - 1) ~~ self size ifTrue:[ |
3891 | 662 |
"/ |
663 |
"/ no longer synchrounous |
|
664 |
"/ |
|
665 |
^ self lostSynchronisation |
|
1451 | 666 |
]. |
667 |
||
1390 | 668 |
absY0 := self yAbsoluteOfLine:start. |
1457 | 669 |
absY1 := self yAbsoluteOfLine:stop + 1. |
1390 | 670 |
dltY := absY1 - absY0. |
671 |
||
3712 | 672 |
newLines := startOfLinesY. "/ copy. |
2385 | 673 |
newLines removeFromIndex:(start + 1) toIndex:(stop + 1). |
1390 | 674 |
|
1457 | 675 |
(start + 1) to:newSz do:[:i| |
3891 | 676 |
absY0 := newLines at:i. |
677 |
newLines at:i put:(absY0 - dltY). |
|
1390 | 678 |
]. |
2385 | 679 |
startOfLinesY := newLines. |
1390 | 680 |
|
681 |
orgY := viewOrigin y. |
|
682 |
orgX := viewOrigin x. |
|
683 |
||
684 |
absY0 := self yAbsoluteOfLine:start. |
|
685 |
absY1 := absY0 + dltY. |
|
686 |
visY0 := absY0 - orgY. |
|
687 |
visY1 := absY1 - orgY. |
|
688 |
maxHg := height - margin. |
|
689 |
||
2408 | 690 |
(self size == 0 or:[(orgY ~~ 0 and:[self maxViewOriginY == 0])]) ifTrue:[ |
3891 | 691 |
(orgX ~~ 0 or:[orgY ~~ 0]) ifTrue:[ |
692 |
self originWillChange. |
|
693 |
viewOrigin := 0@0. |
|
694 |
self originChanged:((orgX @ orgY) negated). |
|
695 |
]. |
|
696 |
self invalidate. |
|
697 |
^ self contentsChanged |
|
1390 | 698 |
]. |
699 |
||
700 |
visY0 < margin ifTrue:[ |
|
5196 | 701 |
doRedraw := visY1 > margin. |
702 |
doRedraw ifTrue:[dltY := visY0] ifFalse:[dltY := dltY negated]. |
|
3891 | 703 |
|
704 |
self originWillChange. |
|
705 |
viewOrigin := viewOrigin x @ (dltY + orgY). |
|
706 |
self originChanged:(0 @ dltY). |
|
1390 | 707 |
] ifFalse:[ |
5196 | 708 |
doRedraw := visY0 < maxHg |
1390 | 709 |
]. |
1773
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
710 |
visY0 := visY0 max:margin. |
9dba0f0dda0e
invalidate uptoend not all if a damage exists (insert/remove)
ca
parents:
1753
diff
changeset
|
711 |
|
1457 | 712 |
self hasDamage ifTrue:[ |
3891 | 713 |
self invalidate:(Rectangle left:0 |
714 |
top:visY0 |
|
715 |
width:width |
|
716 |
height:height - visY0). |
|
717 |
||
5196 | 718 |
doRedraw := false. |
1457 | 719 |
]. |
1390 | 720 |
|
5196 | 721 |
(shown and:[doRedraw]) ifTrue:[ |
3891 | 722 |
cpyHg := maxHg - visY1. |
723 |
||
724 |
cpyHg > 20 ifTrue:[ |
|
725 |
self catchExpose. |
|
726 |
self copyFrom:self x:0 y:visY1 toX:0 y:visY0 |
|
727 |
width:width height:cpyHg async:true. |
|
728 |
self waitForExpose. |
|
729 |
visY0 := visY0 + cpyHg. |
|
730 |
]. |
|
731 |
||
732 |
self invalidateX:margin |
|
733 |
y:visY0 |
|
734 |
width:width - margin - margin |
|
735 |
height:(maxHg - visY0). |
|
1390 | 736 |
]. |
737 |
self contentsChanged. |
|
738 |
! |
|
739 |
||
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
740 |
update:what with:aPara from:chgObj |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
741 |
"catch and handle any notification raised from the list model |
2745 | 742 |
or list holder" |
743 |
||
744 |
chgObj == self listHolder ifTrue:[ |
|
3728 | 745 |
self list:chgObj value. |
746 |
^ self. |
|
2745 | 747 |
]. |
748 |
||
749 |
chgObj == self list ifTrue:[ |
|
3728 | 750 |
listRenderer withinUpdateFromListDo:[ |
751 |
self updateFromList:what with:aPara. |
|
752 |
]. |
|
753 |
^ self. |
|
2644 | 754 |
]. |
755 |
||
2745 | 756 |
super update:what with:aPara from:chgObj |
2644 | 757 |
! |
758 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
759 |
updateFromList:what with:aParameter |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
760 |
"called if the list changed" |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
761 |
|
2644 | 762 |
|arg1 arg2| |
763 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
764 |
aParameter isCollection ifFalse:[ |
3728 | 765 |
what == #at: ifTrue:[self lineChangedAt:aParameter with:nil. ^ self]. |
766 |
what == #insert: ifTrue:[self listChangedInsert:aParameter nItems:1. ^ self]. |
|
767 |
what == #remove: ifTrue:[self listChangedRemove:aParameter toIndex:aParameter. ^ self]. |
|
768 |
||
769 |
self list:(self list). "/ reload list |
|
770 |
^ self. |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
771 |
]. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
772 |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
773 |
arg1 := aParameter at:1. |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
774 |
arg2 := aParameter at:2. |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
775 |
|
2644 | 776 |
(arg1 == 1 and:[arg2 == self size]) ifTrue:[ |
3728 | 777 |
self list:(self list). "/ reload list |
778 |
^ self |
|
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
779 |
]. |
1390 | 780 |
|
2644 | 781 |
what == #at: ifTrue:[self lineChangedAt:arg1 with:arg2. ^ self]. |
782 |
what == #insertCollection: ifTrue:[self listChangedInsert:arg1 nItems:arg2. ^ self]. |
|
783 |
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
|
784 |
|
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
785 |
what == #replace: ifTrue:[ |
3728 | 786 |
arg1 to:arg2 do:[:i|self lineChangedAt:i with:nil]. |
787 |
^ self |
|
1995 | 788 |
]. |
2981 | 789 |
self halt:'oops - general change'. |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
790 |
self list:(self list). "/ reload list |
1390 | 791 |
! ! |
792 |
||
793 |
!ListModelView methodsFor:'drawing'! |
|
794 |
||
2643 | 795 |
drawElementsFrom:start to:stop x:x y:y w:w |
2304 | 796 |
"draw lines from start to stop. |
797 |
clipping and clearing the background is already done |
|
1399 | 798 |
" |
2304 | 799 |
|item |
800 |
y0 "{ Class:SmallInteger }" |
|
801 |
y1 "{ Class:SmallInteger }" |
|
802 |
x0 "{ Class:SmallInteger }" |
|
803 |
| |
|
804 |
self paint:fgColor on:bgColor. |
|
805 |
||
806 |
x0 := textStartLeft - viewOrigin x. |
|
807 |
y1 := y. |
|
808 |
||
809 |
start to:stop do:[:i| |
|
3728 | 810 |
item := self at:i ifAbsent:self. "/ list changed during draw |
811 |
item == self ifTrue:[^ self]. |
|
812 |
||
813 |
y0 := y1. |
|
814 |
y1 := self yVisibleOfLine:(i + 1). |
|
815 |
||
816 |
item notNil ifTrue:[ |
|
817 |
listRenderer display:item atX:x0 y:y0 lineHeight:(y1 - y0). |
|
818 |
] |
|
2304 | 819 |
] |
1390 | 820 |
! |
821 |
||
4319 | 822 |
drawFrom:start to:stop x:xLft y:yTop w:aWidth |
2643 | 823 |
"draw lines from start to stop. Test whether a new clip |
4319 | 824 |
must be setup." |
825 |
||
2643 | 826 |
|maxX w| |
827 |
||
3728 | 828 |
maxX := listRenderer maxItemWidthOrNil. |
2644 | 829 |
w := aWidth. |
4319 | 830 |
maxX notNil ifTrue:[ |
831 |
|clip| |
|
832 |
||
833 |
maxX := maxX - viewOrigin x. |
|
834 |
maxX > xLft ifFalse:[ |
|
835 |
^ self. |
|
836 |
]. |
|
837 |
w := maxX - xLft min:aWidth. |
|
4478 | 838 |
clip := self clippingBoundsOrNil. |
839 |
clip notNil ifTrue:[ |
|
840 |
clip := clip copy. |
|
4319 | 841 |
clip width:w |
842 |
] ifFalse:[ |
|
843 |
clip := Rectangle |
|
844 |
left:xLft |
|
845 |
top:yTop |
|
846 |
width:w |
|
847 |
height:(height - yTop - margin). |
|
848 |
]. |
|
4478 | 849 |
self clippingBounds:clip. |
2643 | 850 |
]. |
4319 | 851 |
self |
852 |
drawElementsFrom:start |
|
853 |
to:stop |
|
854 |
x:xLft |
|
855 |
y:yTop |
|
856 |
w:w. |
|
2643 | 857 |
! |
858 |
||
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
859 |
drawSelectionFrameFrom:start to:stop x:x y:y w:w |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
860 |
"What to do here?" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
861 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
862 |
"Created: / 24-04-2013 / 14:07:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
863 |
! |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
864 |
|
2304 | 865 |
invalidateLineAt:aLineNr |
866 |
"add a damage to redraw a line specified by its line number to the |
|
867 |
input event queue. |
|
1390 | 868 |
" |
2322 | 869 |
^ self invalidateLineAt:aLineNr fromX:0. |
870 |
! |
|
871 |
||
872 |
invalidateLineAt:aLineNr fromX:x |
|
873 |
"add a damage to redraw a line specified by its line number to the |
|
874 |
input event queue. |
|
875 |
" |
|
1390 | 876 |
|y0 "{ Class:SmallInteger }" |
877 |
y1 "{ Class:SmallInteger }" |
|
878 |
yB "{ Class:SmallInteger }" |
|
2322 | 879 |
x0 "{ Class:SmallInteger }" |
880 |
xR "{ Class:SmallInteger }" |
|
1390 | 881 |
| |
882 |
||
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
883 |
(shown and:[aLineNr notNil and:[aLineNr > 0]]) ifFalse:[ |
3728 | 884 |
^ self |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
885 |
]. |
1390 | 886 |
|
2322 | 887 |
xR := width - margin. |
888 |
x0 := x max:margin. |
|
889 |
x0 < xR ifFalse:[ ^ self]. |
|
890 |
||
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
891 |
yB := height - margin. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
892 |
y0 := (self yVisibleOfLine:aLineNr) max:margin. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
893 |
|
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
894 |
y0 < yB ifTrue:[ |
3728 | 895 |
y1 := (self yVisibleOfLine:(aLineNr + 1)) min:yB. |
896 |
||
897 |
y1 > y0 ifTrue:[ |
|
898 |
self invalidateX:x0 y:y0 width:(xR - x0) height:(y1 - y0) repairNow:false. |
|
899 |
] |
|
2304 | 900 |
]. |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
901 |
! |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
902 |
|
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
903 |
redraw |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
904 |
"redraw complete view |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
905 |
" |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
906 |
self redrawX:0 y:0 width:width height:height. |
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
907 |
|
1390 | 908 |
|
909 |
! |
|
910 |
||
911 |
redrawX:x y:y width:w height:h |
|
3728 | 912 |
"redraw part of myself immediately, given logical coordinates |
1390 | 913 |
" |
5756 | 914 |
|numLines start stop yAbs yStart| |
1390 | 915 |
|
916 |
shown ifFalse:[^ self]. |
|
917 |
||
5756 | 918 |
"/ the list may not change during the redraw |
5758 | 919 |
list synchronized:[ |
5756 | 920 |
numLines := list size. |
921 |
(self startOfLinesY size) == (numLines + 1) ifFalse:[ |
|
922 |
"oops, recompute the height of the contents (the first time after creation). |
|
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
923 |
" |
5756 | 924 |
self recomputeHeightOfContents. |
925 |
||
926 |
self startOfLinesY size > 1 ifTrue:[ |
|
927 |
"oops, the contents height changed |
|
928 |
" |
|
929 |
self invalidate. |
|
930 |
self contentsChanged. |
|
931 |
^ self |
|
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
932 |
]. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
933 |
]. |
5756 | 934 |
"/ widthOfContents isNil ifTrue:[ |
935 |
"/ self preferredExtent |
|
936 |
"/ ]. |
|
937 |
yStart := y. |
|
938 |
start := self yVisibleToLineNr:y. |
|
939 |
||
940 |
start notNil ifTrue:[ |
|
941 |
yAbs := y + h. |
|
942 |
stop := self yVisibleToLineNr:yAbs. |
|
943 |
||
944 |
stop isNil ifTrue:[ |
|
945 |
stop := numLines. |
|
946 |
] ifFalse:[ |y0| |
|
947 |
stop := stop min:numLines. |
|
948 |
y0 := self startOfLinesY at:stop ifAbsent:nil. |
|
949 |
y0 isNil ifTrue:[^ self]. "/ oops, lines differ (will be changed) |
|
950 |
||
951 |
yAbs == y0 ifTrue:[ |
|
952 |
stop := (stop - 1) max:start |
|
953 |
]. |
|
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
954 |
]. |
5756 | 955 |
|
956 |
start > stop ifTrue:[ |
|
957 |
start := stop := nil. |
|
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
958 |
] ifFalse:[ |
5756 | 959 |
(listRenderer validateDrawableItemsFrom:start to:stop) ifFalse:[ |
960 |
self invalidate. |
|
961 |
^ self. |
|
962 |
]. |
|
963 |
yStart := self yVisibleOfLine:start. |
|
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
964 |
]. |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
965 |
]. |
5756 | 966 |
gc paint:bgColor. |
967 |
gc fillRectangleX:x y:y width:w height:h. |
|
968 |
||
969 |
StopRedrawSignal handle:[:ex| |
|
970 |
"/ an item changed its dimension during drawing, draw is aborted |
|
971 |
self invalidate |
|
972 |
] do:[ |
|
973 |
start notNil ifTrue:[ |
|
974 |
listRenderer showItemInAdditionToColumns ifTrue:[ |
|
975 |
self drawFrom:start to:stop x:x y:yStart w:w. |
|
976 |
] ifFalse:[ |
|
977 |
self drawSelectionFrameFrom:start to:stop x:x y:yStart w:w. |
|
978 |
]. |
|
979 |
]. |
|
980 |
listRenderer postRedrawX:x y:yStart w:w from:start to:stop. |
|
981 |
]. |
|
982 |
] |
|
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
983 |
|
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
984 |
"Modified: / 24-11-2010 / 19:03:56 / cg" |
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
985 |
"Modified: / 24-04-2013 / 14:07:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1390 | 986 |
! ! |
987 |
||
3715 | 988 |
!ListModelView methodsFor:'enumerating'! |
989 |
||
990 |
visibleLinesAndItemsDo:aTwoArgBlock |
|
991 |
"enumerate over each visible item" |
|
992 |
||
993 |
|lineNr item| |
|
994 |
||
995 |
shown ifFalse:[^ self]. |
|
996 |
||
997 |
lineNr := self yVisibleToLineNr:1. |
|
998 |
lineNr isNil ifTrue:[ ^ self ]. |
|
999 |
||
1000 |
[ item := list at:lineNr ifAbsent:[ ^ self ]. |
|
3728 | 1001 |
aTwoArgBlock value:lineNr value:item. |
1002 |
lineNr := lineNr + 1. |
|
1003 |
(self yVisibleOfLine:lineNr) < height |
|
3715 | 1004 |
] whileTrue. |
1005 |
! ! |
|
1006 |
||
1390 | 1007 |
!ListModelView methodsFor:'event handling'! |
1008 |
||
1009 |
keyPress:aKey x:x y:y |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1010 |
"a key was pressed - handle page-keys here" |
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1011 |
|
1390 | 1012 |
<resource: #keyboard( #PreviousPage #NextPage #HalfPageUp #HalfPageDown |
3728 | 1013 |
#BeginOfText #EndOfText #ScrollUp #ScrollDown |
1014 |
)> |
|
1390 | 1015 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1016 |
|n| |
1390 | 1017 |
|
2408 | 1018 |
self size ~~ 0 ifTrue:[ |
3728 | 1019 |
(aKey == #PreviousPage) ifTrue:[^ self pageUp]. |
1020 |
(aKey == #NextPage) ifTrue:[^ self pageDown]. |
|
1021 |
(aKey == #HalfPageUp) ifTrue:[^ self halfPageUp]. |
|
1022 |
(aKey == #HalfPageDown) ifTrue:[^ self halfPageDown]. |
|
1023 |
(aKey == #BeginOfText) ifTrue:[^ self scrollToTop]. |
|
1024 |
(aKey == #EndOfText) ifTrue:[^ self scrollToBottom]. |
|
1025 |
||
1026 |
(aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[ |
|
1027 |
n := 1 + (self sensor compressKeyPressEventsWithKey:aKey). |
|
1028 |
n := n * self verticalScrollStep. |
|
1029 |
||
1030 |
aKey == #ScrollUp ifTrue:[self scrollUp:n] |
|
1031 |
ifFalse:[self scrollDown:n]. |
|
1032 |
^ self |
|
1033 |
]. |
|
1390 | 1034 |
]. |
1035 |
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
|
1036 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1037 |
|
5668 | 1038 |
keyboardZoom:largerBoolean |
5280 | 1039 |
"CTRL+/- zoom action" |
1040 |
||
5668 | 1041 |
self fontLargerOrSmaller:largerBoolean |
5280 | 1042 |
! |
1043 |
||
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1044 |
sizeChanged:how |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1045 |
previousExtent := self extent. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1046 |
listRenderer sizeChanged:how. |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1047 |
super sizeChanged:how. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1048 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1049 |
"Modified: / 17-04-2013 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1390 | 1050 |
! ! |
1051 |
||
1554 | 1052 |
!ListModelView methodsFor:'event simulation'! |
1053 |
||
1054 |
syncronizeEvents |
|
2708 | 1055 |
<resource:#obsolete> |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1056 |
self obsoleteMethodWarning:'no longer supported'. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1057 |
^ false |
1554 | 1058 |
! |
1059 |
||
1060 |
syncronizeEvents:aBoolean |
|
2708 | 1061 |
<resource:#obsolete> |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1062 |
self obsoleteMethodWarning:'no longer supported'. |
1554 | 1063 |
! ! |
1064 |
||
1390 | 1065 |
!ListModelView methodsFor:'fetch resources'! |
1066 |
||
1067 |
colorOnDevice:aColor |
|
1068 |
"fetch a device colors |
|
1069 |
" |
|
5000 | 1070 |
^ aColor notNil ifTrue:[aColor onDevice:device] ifFalse:[nil] |
1390 | 1071 |
! |
1072 |
||
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
1073 |
imageOnMyDevice:anImage |
4609
6b04d0372a95
Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents:
4578
diff
changeset
|
1074 |
"associate image to device and returns the new image." |
6b04d0372a95
Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents:
4578
diff
changeset
|
1075 |
|
6b04d0372a95
Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents:
4578
diff
changeset
|
1076 |
anImage isNil ifTrue:[^ nil]. |
5000 | 1077 |
^ anImage onDevice:device. |
1390 | 1078 |
! ! |
1079 |
||
1417 | 1080 |
!ListModelView methodsFor:'focus handling'! |
1081 |
||
1082 |
wantsFocusWithButtonPress |
|
1083 |
"catch the keyboard focus on button click |
|
1084 |
" |
|
1085 |
^ true |
|
1086 |
||
1087 |
||
1088 |
! |
|
1089 |
||
1090 |
wantsFocusWithPointerEnter |
|
1091 |
"views which like to take the keyboard focus |
|
1092 |
when the pointer enters can do so by redefining this |
|
1093 |
to return true" |
|
1094 |
||
1095 |
^ true |
|
1096 |
||
1097 |
! ! |
|
1098 |
||
2501 | 1099 |
!ListModelView methodsFor:'initialization & release'! |
1390 | 1100 |
|
1101 |
create |
|
1102 |
"fetch device dependent resources |
|
1103 |
" |
|
1104 |
super create. |
|
1105 |
self fetchResources. |
|
1106 |
! |
|
1107 |
||
1108 |
initStyle |
|
1109 |
"setup viewStyle specifics |
|
1110 |
" |
|
1111 |
super initStyle. |
|
1112 |
||
1113 |
DefaultBackgroundColor notNil ifTrue:[ |
|
3926 | 1114 |
viewBackground := DefaultBackgroundColor |
1390 | 1115 |
]. |
4569 | 1116 |
lineSpacing := 2. |
1390 | 1117 |
textStartLeft := 2. |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1118 |
textStartTop := 2. |
1390 | 1119 |
fgColor := DefaultForegroundColor. |
1120 |
bgColor := viewBackground. |
|
1121 |
startOfLinesY := OrderedCollection new. |
|
1122 |
||
3926 | 1123 |
self font:SelectionInListView defaultFont. |
1124 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1125 |
startOfLinesY add:(textStartTop + margin). "/ top inset of first line |
1390 | 1126 |
|
1127 |
DefaultShadowColor notNil ifTrue:[ |
|
3926 | 1128 |
shadowColor := DefaultShadowColor |
1390 | 1129 |
]. |
1130 |
||
1131 |
DefaultLightColor notNil ifTrue:[ |
|
3926 | 1132 |
lightColor := DefaultLightColor |
1390 | 1133 |
]. |
3926 | 1134 |
|
1135 |
"Modified: / 14-08-2010 / 12:24:02 / cg" |
|
1390 | 1136 |
! |
1137 |
||
1138 |
initialize |
|
1139 |
"setup default attributes |
|
1140 |
" |
|
1141 |
super initialize. |
|
1142 |
||
2261 | 1143 |
viewOrigin := 0@0. |
1144 |
bitGravity := #NorthWest. |
|
1145 |
enabled := true. |
|
1146 |
autoScroll := true. |
|
1827 | 1147 |
scrollWhenUpdating := #beginOfText. |
2261 | 1148 |
hasConstantHeight := false. |
2352 | 1149 |
|
3728 | 1150 |
listRenderer isNil ifTrue:[ |
3891 | 1151 |
listRenderer := self class defaultRenderer forView:self. |
2352 | 1152 |
]. |
2600 | 1153 |
self list:(self newDefaultList). |
1390 | 1154 |
! |
1155 |
||
1562 | 1156 |
mapped |
1157 |
"recompute list |
|
1158 |
" |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1159 |
"/ shown ifFalse:[ |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1160 |
"/ self recomputeHeightOfContents. |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1161 |
"/ self contentsChanged. "/ is computeEditorLayout what you want ? |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1162 |
"/ ]. |
3728 | 1163 |
listRenderer mapped. |
1562 | 1164 |
super mapped |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1165 |
|
1562 | 1166 |
! |
1167 |
||
1390 | 1168 |
recreate |
1832 | 1169 |
"sent after a snapin or a migration, reinit for new device" |
1828 | 1170 |
|
1390 | 1171 |
super recreate. |
1172 |
self fetchResources. |
|
1796
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1173 |
! |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1174 |
|
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1175 |
reinitialize |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1176 |
"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
|
1177 |
" |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1178 |
super reinitialize. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1179 |
self recomputeHeightOfContents. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1180 |
self contentsChanged. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1181 |
|
2156 | 1182 |
! |
1183 |
||
1184 |
release |
|
1185 |
"remove dependencies |
|
1186 |
" |
|
3728 | 1187 |
listRenderer release. |
2643 | 1188 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1189 |
self listHolder removeDependent:self. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1190 |
self list removeDependent:self. |
2156 | 1191 |
|
1192 |
super release |
|
1390 | 1193 |
! ! |
1194 |
||
1195 |
!ListModelView methodsFor:'private'! |
|
1196 |
||
1457 | 1197 |
hasDamage |
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1198 |
"return true, if any damage events (i.e. expose or resize) are pending" |
1457 | 1199 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1200 |
^ self sensor hasDamageFor:self |
1457 | 1201 |
! |
1202 |
||
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1203 |
startOfLinesY |
3728 | 1204 |
"returns a collection of absolute Y-positions per line. |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1205 |
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
|
1206 |
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
|
1207 |
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
|
1208 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1209 |
^ startOfLinesY |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1210 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1211 |
|
2640 | 1212 |
xAbsoluteOfItem:anItem |
1213 |
"returns the absolute x of the labeled text |
|
1214 |
" |
|
1215 |
^ (self xVisibleOfItem:anItem) + viewOrigin x. |
|
1216 |
! |
|
1217 |
||
1218 |
xVisibleOfItem:anItem |
|
1219 |
"returns the visible x of the labeled text |
|
1220 |
" |
|
1221 |
^ textStartLeft - viewOrigin x |
|
1222 |
! |
|
1223 |
||
1390 | 1224 |
yAbsoluteOfLine:aLineNr |
1225 |
"given a lineNr, return y-coordinate absolute |
|
1226 |
" |
|
4578 | 1227 |
|y y2 y1 cache| |
1228 |
||
1229 |
cache := self startOfLinesY. |
|
1230 |
||
1231 |
(y := cache at:aLineNr ifAbsent:nil) notNil ifTrue:[ |
|
1232 |
^ y |
|
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
1233 |
]. |
1744 | 1234 |
|
1235 |
"/ recompute a y position |
|
4578 | 1236 |
y1 := cache at:1 ifAbsent:textStartTop. |
1237 |
y2 := cache at:2 ifAbsent:(textStartTop + 16). |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1238 |
^ aLineNr * (y2 - y1) + y1 |
1390 | 1239 |
! |
1240 |
||
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1241 |
yAbsoluteToLineNr:yAbsolute |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1242 |
"returns the line number for a given physical y coordinate |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1243 |
or nil if beyond of list. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1244 |
" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1245 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1246 |
|cache yCache |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1247 |
yAbs "{ Class: SmallInteger}" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1248 |
size "{ Class: SmallInteger}" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1249 |
ictr "{ Class: SmallInteger}" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1250 |
yRun "{ Class: SmallInteger}" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1251 |
| |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1252 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1253 |
yAbs := yAbsolute. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1254 |
cache := self startOfLinesY. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1255 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1256 |
(size := cache size) < 2 ifTrue:[ |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1257 |
"/ empty list |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1258 |
(yAbs between:textStartTop and:textStartTop+16) ifTrue:[^ 1]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1259 |
^ nil |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1260 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1261 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1262 |
yCache := cache at:size ifAbsent:nil. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1263 |
yCache isNil ifTrue:[ ^ nil ]. "/ out of list |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1264 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1265 |
yRun := yCache. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1266 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1267 |
yAbs >= yRun ifTrue:[ |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1268 |
yAbs == yRun ifTrue:[ ^ size - 1]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1269 |
^ nil "/ out of list |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1270 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1271 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1272 |
constantHeight notNil ifTrue:[ |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1273 |
yAbs := yAbs - (cache at:1). |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1274 |
yAbs < constantHeight ifTrue:[ ^ 1 ]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1275 |
^ yAbs // constantHeight + 1 |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1276 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1277 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1278 |
ictr := yAbs // (cache at:2). |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1279 |
ictr < 1 ifTrue:[ ictr := 1 ] |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1280 |
ifFalse:[ ictr := ictr min:size ]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1281 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1282 |
yRun := cache at:ictr. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1283 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1284 |
yRun > yAbs ifTrue:[ |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1285 |
[(ictr := ictr - 1) > 0 ] whileTrue:[ |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1286 |
yRun := cache at:ictr. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1287 |
yRun <= yAbs ifTrue:[ ^ ictr ]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1288 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1289 |
^ 1 |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1290 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1291 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1292 |
[ yRun ~~ yAbs ] whileTrue:[ |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1293 |
ictr := ictr + 1. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1294 |
yRun := cache at:ictr. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1295 |
yRun > yAbs ifTrue:[ ^ ictr - 1 ]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1296 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1297 |
^ ictr |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1298 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1299 |
"Created: / 18-04-2013 / 10:03:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1300 |
! |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1301 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1302 |
yAbsoluteToRowNr:yVisible |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1303 |
"for protocol compatibility with DSVColumnView" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1304 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1305 |
^ self yAbsoluteToLineNr:yVisible |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1306 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1307 |
"Created: / 18-04-2013 / 10:05:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1308 |
! |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1309 |
|
1390 | 1310 |
yVisibleOfLine:aLineNr |
1311 |
"given a lineNr, return y-coordinate in view |
|
1312 |
" |
|
1744 | 1313 |
^ (self yAbsoluteOfLine:aLineNr) - viewOrigin y |
1390 | 1314 |
|
1315 |
||
1316 |
! |
|
1317 |
||
1318 |
yVisibleToLineNr:yVisible |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1319 |
"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
|
1320 |
or nil if beyond of list. |
1390 | 1321 |
" |
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1322 |
^self yAbsoluteToLineNr: yVisible + viewOrigin y. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1323 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1324 |
"Modified: / 18-04-2013 / 10:04:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2464
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1325 |
! |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1326 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1327 |
yVisibleToRowNr:yVisible |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1328 |
"for protocol compatibility with DSVColumnView" |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1329 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1330 |
^ self yVisibleToLineNr:yVisible |
1390 | 1331 |
! ! |
1332 |
||
1333 |
!ListModelView methodsFor:'protocol'! |
|
1334 |
||
1335 |
fetchResources |
|
1336 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1337 |
*** called after a create or snapin to fetch all device resources |
|
1338 |
" |
|
1339 |
fgColor := self colorOnDevice:fgColor. |
|
1340 |
bgColor := self colorOnDevice:bgColor. |
|
1341 |
! |
|
1342 |
||
3533 | 1343 |
heightForLines:numberOfLines |
1344 |
|h| |
|
1345 |
||
1346 |
h := self lineHeightFor:'Yg'. |
|
1347 |
^ h * numberOfLines |
|
1348 |
! |
|
1349 |
||
2352 | 1350 |
lineHeightFor:anItem |
1351 |
"returns the computed line height for an item |
|
1390 | 1352 |
" |
3728 | 1353 |
^ lineSpacing + (listRenderer heightFor:anItem) |
1390 | 1354 |
! |
1355 |
||
1356 |
listSizeChanged:anIndex nLines:noLines |
|
1357 |
"list size changed; information is stored to recompute the |
|
1358 |
width if required( preferredExtent, horizontal scroller ... ). |
|
1359 |
see: widthOfContents |
|
1360 |
*** if nLines is negative, lines are removed otherwise added. |
|
1361 |
" |
|
1362 |
|start "{ Class:SmallInteger }" |
|
1363 |
stop "{ Class:SmallInteger }" |
|
1364 |
size "{ Class:SmallInteger }" |
|
1365 |
| |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1366 |
"/ preferredExtent := nil. |
1390 | 1367 |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1368 |
cachedPreferredExtent := nil. |
1390 | 1369 |
widthOfContents isNil ifTrue:[ "/ recompute whole list |
3728 | 1370 |
^ self |
1390 | 1371 |
]. |
1372 |
||
2408 | 1373 |
(noLines < 0 or:[(size := self size) <= noLines]) ifTrue:[ |
3728 | 1374 |
widthOfContents := nil. "/ force recompute whole list |
1375 |
^ self |
|
1390 | 1376 |
]. |
1377 |
||
1378 |
stop := anIndex + noLines - 1. "/ recompute a range |
|
1379 |
start := anIndex. |
|
1380 |
||
1381 |
computeWidthInRange notNil ifTrue:[ |
|
3728 | 1382 |
start := computeWidthInRange y. |
1383 |
stop < start ifTrue:[stop := start min:size]. |
|
1384 |
start := (computeWidthInRange x) min:anIndex. |
|
1390 | 1385 |
]. |
1386 |
computeWidthInRange := start@stop |
|
1387 |
! |
|
1388 |
||
1457 | 1389 |
lostSynchronisation |
1390 |
"called when the changes derived from the model are faster than the handling |
|
1391 |
" |
|
3892 | 1392 |
|
1393 |
self recomputeHeightOfContents. |
|
1394 |
self invalidate. |
|
1395 |
self contentsChanged |
|
1457 | 1396 |
! |
1397 |
||
2644 | 1398 |
newDefaultList |
1399 |
"creates and returns a new default list class, on default a List |
|
1400 |
" |
|
1401 |
^ List new |
|
1402 |
! |
|
1403 |
||
1390 | 1404 |
widthOfWidestLineBetween:firstLine and:lastLine |
1405 |
"return the width in pixels of the widest line in a range |
|
4858 | 1406 |
- used to optimize scrolling, by limiting the scrolled area; |
1407 |
not for scrollbar or other width related stuff which should be exact." |
|
1408 |
||
2645 | 1409 |
|item width| |
1410 |
||
3728 | 1411 |
width := listRenderer widthOfWidestLineBetween:firstLine and:lastLine. |
2644 | 1412 |
width notNil ifTrue:[^ width]. |
1413 |
||
1390 | 1414 |
width := textStartLeft. |
1415 |
||
1416 |
firstLine to:lastLine do:[:anIndex| |
|
4858 | 1417 |
item := self at:anIndex ifAbsent:nil. |
1418 |
||
1419 |
item isNil ifTrue:[^ width + textStartLeft]. |
|
1420 |
||
1421 |
width := (listRenderer widthFor:item) max:width |
|
1390 | 1422 |
]. |
1423 |
^ width + textStartLeft |
|
1424 |
! ! |
|
1425 |
||
1820 | 1426 |
!ListModelView methodsFor:'queries'! |
1427 |
||
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1428 |
isLineVisible:aLineNr |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1429 |
"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
|
1430 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1431 |
^ self isLineVisible:aLineNr in:self extent |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1432 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1433 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1434 |
isLineVisible:aLineNr in:anExtentPoint |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1435 |
"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
|
1436 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1437 |
|y| |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1438 |
y := self yVisibleOfLine:aLineNr. |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1439 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1440 |
^ (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
|
1441 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1442 |
|
3201 | 1443 |
lineIsFullyVisible:aLineNr |
1444 |
"returns true if the line is fully visible" |
|
1445 |
||
1446 |
|y| |
|
1447 |
||
1448 |
shown ifFalse:[^ false]. |
|
1449 |
||
1450 |
y := self yVisibleOfLine:aLineNr. |
|
1451 |
||
1452 |
(y between:0 and:height) ifTrue:[ |
|
3728 | 1453 |
y := self yVisibleOfLine:(aLineNr + 1). |
1454 |
y <= height ifTrue:[^ true ]. |
|
3201 | 1455 |
]. |
1456 |
^ false |
|
1457 |
! |
|
1458 |
||
1820 | 1459 |
size |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1460 |
"returns the number of list entries |
1820 | 1461 |
" |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1462 |
^ self list size |
1820 | 1463 |
! ! |
1464 |
||
1390 | 1465 |
!ListModelView methodsFor:'recomputation'! |
1466 |
||
1467 |
preferredExtent |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1468 |
"returns the preferred extent" |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1469 |
|
1390 | 1470 |
|x y| |
1471 |
||
3576
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1472 |
"/ If I have an explicit preferredExtent.. |
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1473 |
explicitExtent notNil ifTrue:[ |
3728 | 1474 |
^ explicitExtent |
3576
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1475 |
]. |
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1476 |
|
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1477 |
"/ If I have a cached preferredExtent value.. |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1478 |
preferredExtent notNil ifTrue:[ |
3728 | 1479 |
^ preferredExtent |
1390 | 1480 |
]. |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1481 |
cachedPreferredExtent isNil ifTrue:[ |
3728 | 1482 |
y := self heightOfContents. |
1483 |
x := self widthOfContents. |
|
1484 |
cachedPreferredExtent := x@y |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1485 |
]. |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1486 |
^ cachedPreferredExtent |
1390 | 1487 |
! |
1488 |
||
1489 |
recomputeHeightOfContents |
|
1490 |
"recompute all the y positions |
|
1491 |
" |
|
1643 | 1492 |
|newList |
3728 | 1493 |
yAbs "{ Class: SmallInteger }" |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1494 |
size "{ Class: SmallInteger }"| |
1390 | 1495 |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1496 |
yAbs := (textStartTop + margin). "/ top inset of first line |
2408 | 1497 |
size := self size. |
1643 | 1498 |
newList := OrderedCollection new:(size + 1). |
1499 |
newList add:yAbs. |
|
1390 | 1500 |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1501 |
size ~~ 0 ifTrue:[ |
4569 | 1502 |
1 to:size do:[:anIndex| |
4635 | 1503 |
yAbs := yAbs + (self heightOfLineAt:anIndex). |
4569 | 1504 |
newList add:yAbs |
1505 |
]. |
|
1390 | 1506 |
]. |
1643 | 1507 |
startOfLinesY := newList. |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1508 |
cachedPreferredExtent := nil. |
1390 | 1509 |
! ! |
1510 |
||
1511 |
!ListModelView methodsFor:'scroller interface'! |
|
1512 |
||
2644 | 1513 |
getWidthOfContents |
1514 |
^ widthOfContents |
|
1515 |
! |
|
1516 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1517 |
heightOfAnyNonNilItem |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1518 |
"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
|
1519 |
|
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1520 |
|item| |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1521 |
|
4635 | 1522 |
item := list |
1523 |
detect:[:i | i notNil] |
|
1524 |
ifNone:[ ^ lineSpacing + gc font height ]. "arbitrary" |
|
1525 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1526 |
^ self lineHeightFor:item. |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1527 |
! |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1528 |
|
1390 | 1529 |
heightOfContents |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1530 |
"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
|
1531 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1532 |
^ self startOfLinesY last ? 0 |
1390 | 1533 |
! |
1534 |
||
2261 | 1535 |
heightOfLineAt:aLineNr |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1536 |
"returns the height of a line at an index (including lineSpacing...)" |
2261 | 1537 |
|
1538 |
hasConstantHeight ifTrue:[ |
|
3728 | 1539 |
constantHeight isNil ifTrue:[ |
1540 |
constantHeight := self heightOfAnyNonNilItem. |
|
1541 |
]. |
|
1542 |
^ constantHeight |
|
2261 | 1543 |
]. |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1544 |
^ self realHeightOfLineAt:aLineNr |
2261 | 1545 |
! |
1546 |
||
1390 | 1547 |
innerHeight |
1548 |
"returns the inner height of the contents shown |
|
1549 |
" |
|
1550 |
^ height - margin - margin |
|
1551 |
||
1552 |
! |
|
1553 |
||
1554 |
innerWidth |
|
1555 |
"returns the inner width of the contents shown |
|
1556 |
" |
|
1557 |
^ width - margin - margin |
|
1558 |
||
1559 |
! |
|
1560 |
||
1561 |
maxViewOriginY |
|
1562 |
"returns the maximum possible y of the view origin |
|
1563 |
" |
|
1564 |
^ (self heightOfContents - self innerHeight) max:0 |
|
1565 |
||
1566 |
||
1567 |
! |
|
1568 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1569 |
realHeightOfLineAt:aLineNr |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1570 |
"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
|
1571 |
|
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1572 |
|item| |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1573 |
|
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1574 |
item := self at:aLineNr ifAbsent:nil. |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1575 |
item notNil ifTrue:[ |
4500 | 1576 |
^ self lineHeightFor:item |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1577 |
]. |
4635 | 1578 |
^ lineSpacing + gc font height "arbitrary" |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1579 |
! |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1580 |
|
2644 | 1581 |
setWidthOfContents: aWidth |
1582 |
widthOfContents := aWidth. |
|
1583 |
! |
|
1584 |
||
1390 | 1585 |
verticalScrollStep |
3501 | 1586 |
"return the amount to scroll when stepping up/down (also used for mouseWheel)." |
1587 |
||
1390 | 1588 |
^ 10 |
1589 |
! |
|
1590 |
||
1591 |
viewOrigin |
|
5256 | 1592 |
"return the viewOrigin; that's the coordinate of the contents |
1390 | 1593 |
which is shown topLeft in the view. |
1594 |
" |
|
1595 |
^ viewOrigin |
|
1596 |
! |
|
1597 |
||
1598 |
widthOfContents |
|
1599 |
"return the width of the contents in pixels |
|
1600 |
" |
|
1601 |
|range |
|
1602 |
size "{ Class:SmallInteger }" |
|
1603 |
start "{ Class:SmallInteger }" |
|
1604 |
stop "{ Class:SmallInteger }" |
|
1605 |
| |
|
5521 | 1606 |
(widthOfContents notNil and:[computeWidthInRange isNil]) ifFalse:[ |
1607 |
range := computeWidthInRange. |
|
1608 |
computeWidthInRange := nil. |
|
1609 |
"/ preferredExtent := nil. |
|
1610 |
"/ cachedPreferredExtent := nil. |
|
1611 |
||
1612 |
size := self size. |
|
1613 |
||
1614 |
size == 0 ifTrue:[ |
|
1615 |
widthOfContents := 20. |
|
3891 | 1616 |
] ifFalse:[ |
5521 | 1617 |
widthOfContents isNil ifTrue:[ |
1618 |
widthOfContents := self widthOfWidestLineBetween:1 and:size |
|
1619 |
] ifFalse:[ |
|
1620 |
start := range x. |
|
1621 |
stop := range y min:size. |
|
1622 |
||
1623 |
start > stop ifFalse:[ |
|
1624 |
size := self widthOfWidestLineBetween:start and:stop. |
|
1625 |
||
1626 |
widthOfContents < size ifTrue:[ |
|
1627 |
widthOfContents := size |
|
1628 |
] |
|
3891 | 1629 |
] |
1630 |
] |
|
5521 | 1631 |
]. |
1632 |
]. |
|
1390 | 1633 |
^ widthOfContents + textStartLeft |
5521 | 1634 |
|
1635 |
"Modified: / 21-03-2017 / 09:55:45 / cg" |
|
1390 | 1636 |
! |
1637 |
||
1638 |
xOriginOfContents |
|
1639 |
"return the horizontal origin of the contents in pixels |
|
1640 |
" |
|
3728 | 1641 |
^ viewOrigin x |
1390 | 1642 |
|
1643 |
! |
|
1644 |
||
1645 |
yOriginOfContents |
|
1646 |
"return the vertical origin of the contents in pixels |
|
1647 |
" |
|
1648 |
^ viewOrigin y |
|
1649 |
||
1650 |
! ! |
|
1651 |
||
1652 |
!ListModelView methodsFor:'scrolling'! |
|
1653 |
||
4858 | 1654 |
basicScrollTo:anOrigin redraw:doRedraw |
1390 | 1655 |
"change origin to have newOrigin be visible at the top-left. |
1656 |
" |
|
1538 | 1657 |
|newOrg dltOrg winGrp |
1390 | 1658 |
innerWT "{ Class:SmallInteger }" |
1659 |
innerHG "{ Class:SmallInteger }" |
|
1660 |
h "{ Class:SmallInteger }" |
|
1661 |
x "{ Class:SmallInteger }" |
|
1662 |
x0 "{ Class:SmallInteger }" |
|
1663 |
x1 "{ Class:SmallInteger }" |
|
1664 |
y "{ Class:SmallInteger }" |
|
1665 |
w "{ Class:SmallInteger }" |
|
1666 |
y0 "{ Class:SmallInteger }" |
|
1667 |
y1 "{ Class:SmallInteger }" |
|
1668 |
dX "{ Class:SmallInteger }" |
|
1669 |
dY "{ Class:SmallInteger }" |
|
1670 |
| |
|
1531 | 1671 |
|
1390 | 1672 |
innerWT := self innerWidth. |
1673 |
innerHG := self innerHeight. |
|
1674 |
||
1675 |
h := viewOrigin y. |
|
1676 |
||
1677 |
(y := anOrigin y) > h ifTrue:[ "/ end of contents |
|
3891 | 1678 |
y > (dY := self maxViewOriginY) ifTrue:[ |
1679 |
y := dY max:h |
|
1680 |
] |
|
1390 | 1681 |
] ifFalse:[ |
3891 | 1682 |
y := y max:0. |
1390 | 1683 |
]. |
1684 |
||
1685 |
(x := anOrigin x) > 0 ifTrue:[ |
|
3891 | 1686 |
x := x min:(self widthOfContents - innerWT). |
1390 | 1687 |
]. |
1688 |
x := x max:0. |
|
1689 |
newOrg := (x @ y). |
|
1690 |
dltOrg := newOrg - viewOrigin. |
|
1691 |
dX := dltOrg x. |
|
1692 |
dY := dltOrg y. |
|
1693 |
||
1694 |
(dX == 0 and:[dY == 0]) ifTrue:[ |
|
3891 | 1695 |
^ self |
1390 | 1696 |
]. |
3891 | 1697 |
|
1534 | 1698 |
dY := dY abs. |
1699 |
dX := dX abs. |
|
1390 | 1700 |
|
4858 | 1701 |
( shown not "/ check if we are shown |
1702 |
or:[(dX ~~ 0 and:[dY ~~ 0]) "/ scroll vertical & horizontal |
|
1703 |
or:[(innerHG - dY < 20 or:[innerWT - dX < 20])]] "/ faster to invalidate screen |
|
1534 | 1704 |
) ifTrue:[ |
3891 | 1705 |
viewOrigin := newOrg. |
1706 |
self originChanged:dltOrg. |
|
4858 | 1707 |
shown ifTrue:[ self invalidate ]. |
3891 | 1708 |
^ self |
1534 | 1709 |
]. |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1710 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1711 |
(winGrp := self windowGroup) notNil ifTrue:[ |
3891 | 1712 |
winGrp processRealExposeEventsFor:self. |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1713 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1714 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1715 |
self originWillChange. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1716 |
|
3892 | 1717 |
(doRedraw and:[shown]) ifFalse:[ |
3891 | 1718 |
viewOrigin := newOrg. |
1719 |
self originChanged:dltOrg. |
|
1720 |
^ self |
|
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1721 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1722 |
|
1531 | 1723 |
self catchExpose. |
1724 |
viewOrigin := newOrg. |
|
1725 |
||
1390 | 1726 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL |
3891 | 1727 |
y0 := y1 := margin + dY. |
1728 |
h := innerHG - dY. |
|
1729 |
||
1730 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0] |
|
1731 |
ifFalse:[y1 := margin. y := y1 + h]. |
|
1732 |
||
1733 |
self copyFrom:self x:margin y:y0 toX:margin y:y1 width:innerWT height:h async:true. |
|
1734 |
self invalidateX:margin y:y width:innerWT height:(innerHG - h). |
|
1390 | 1735 |
|
1736 |
] ifFalse:[ "/ SCROLL HORIZONTAL |
|
3891 | 1737 |
x0 := x1 := dX + margin. |
1738 |
w := innerWT - dX. |
|
1739 |
||
1740 |
dltOrg x < 0 ifTrue:[x0 := x := margin ] |
|
1741 |
ifFalse:[x1 := margin. x := w]. |
|
1742 |
||
1743 |
self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:true. |
|
1744 |
self invalidateX:x y:margin width:(width - w) height:innerHG. |
|
1390 | 1745 |
]. |
1746 |
self originChanged:dltOrg. |
|
1531 | 1747 |
self waitForExpose. |
1748 |
||
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1749 |
winGrp notNil ifTrue:[ |
3891 | 1750 |
winGrp processRealExposeEventsFor:self. |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1751 |
]. |
1390 | 1752 |
! |
1753 |
||
4858 | 1754 |
halfPageDown |
1755 |
"scroll down half a page |
|
1756 |
" |
|
1757 |
self scrollDown:(height // 2). |
|
1758 |
||
1759 |
! |
|
1760 |
||
1761 |
halfPageUp |
|
1762 |
"scroll up half a page |
|
1763 |
" |
|
1764 |
self scrollUp:(height // 2). |
|
1765 |
||
1766 |
! |
|
1767 |
||
1768 |
makeLineVisible:aLnNr |
|
1769 |
"make the line visible |
|
1770 |
" |
|
1771 |
aLnNr notNil ifTrue:[ |
|
1772 |
self scrollToLine:aLnNr |
|
1773 |
]. |
|
1774 |
! |
|
1775 |
||
1776 |
scrollTo:anOrigin redraw:doRedraw |
|
1777 |
"change origin to have newOrigin be visible at the top-left. |
|
1778 |
" |
|
1779 |
|process| |
|
1780 |
||
1781 |
"/ check if we are still in scrolling due to async. processes |
|
1782 |
||
1783 |
((process := activeScrollProcess) notNil and:[process isDead]) ifTrue:[ |
|
1784 |
activeScrollProcess := nil. |
|
1785 |
]. |
|
1786 |
activeScrollProcess notNil ifTrue:[^ self]. |
|
1787 |
activeScrollProcess := Processor activeProcess. |
|
1788 |
self basicScrollTo:anOrigin redraw:doRedraw. |
|
1789 |
activeScrollProcess := nil. |
|
1790 |
! |
|
1791 |
||
1390 | 1792 |
scrollToLine:aLineNumber |
3891 | 1793 |
"make line visible" |
1794 |
||
1744 | 1795 |
|inHg "{ Class:SmallInteger }" |
1796 |
yTop "{ Class:SmallInteger }" |
|
1797 |
orgY "{ Class:SmallInteger }" |
|
3891 | 1798 |
yBot "{ Class:SmallInteger }"| |
1799 |
||
1800 |
(aLineNumber notNil and:[aLineNumber between:1 and:(self size)]) ifFalse:[ |
|
1801 |
^ self |
|
1390 | 1802 |
]. |
1803 |
||
1744 | 1804 |
yTop := self yAbsoluteOfLine:aLineNumber. |
1805 |
inHg := self innerHeight. |
|
1806 |
orgY := viewOrigin y. |
|
1807 |
||
1808 |
yTop > orgY ifTrue:[ |
|
3891 | 1809 |
yBot := self yAbsoluteOfLine:(aLineNumber + 1). |
1810 |
||
1811 |
yBot <= (orgY + inHg) ifTrue:[ |
|
1812 |
^ self |
|
1813 |
]. |
|
1390 | 1814 |
]. |
1744 | 1815 |
yTop := (yTop - (inHg // 2)) max:0. |
1816 |
self scrollTo:(viewOrigin x @ yTop). |
|
1390 | 1817 |
! ! |
1818 |
||
1748 | 1819 |
!ListModelView methodsFor:'scrolling auto'! |
1820 |
||
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1821 |
startAutoScroll:aSelectorOrBlock distance:aDistance |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1822 |
"setup for auto-scroll (when button-press-moving below/above view); |
1748 | 1823 |
- timeDelta for scroll is computed from distance |
1824 |
" |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1825 |
|timeDelta scrollBlock| |
1748 | 1826 |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1827 |
autoScroll ifFalse:[ |
3728 | 1828 |
self stopAutoScroll. |
1829 |
^ self |
|
1748 | 1830 |
]. |
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1831 |
|
1748 | 1832 |
autoScrollBlock notNil ifTrue:[ |
3728 | 1833 |
Processor removeTimedBlock:autoScrollBlock. |
1748 | 1834 |
] ifFalse:[ |
3728 | 1835 |
self compressMotionEvents:false. |
1748 | 1836 |
]. |
1837 |
||
1838 |
timeDelta := 0.5 / (aDistance abs). |
|
1839 |
||
3728 | 1840 |
scrollBlock := |
1841 |
[ |
|
1842 |
aSelectorOrBlock isSymbol ifTrue:[ |
|
1843 |
self perform:aSelectorOrBlock. |
|
1844 |
] ifFalse:[ |
|
1845 |
aSelectorOrBlock value |
|
1846 |
]. |
|
1847 |
autoScrollBlock notNil ifTrue:[ |
|
1848 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
|
1849 |
] |
|
1850 |
]. |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1851 |
|
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1852 |
autoScrollBlock := [self sensor pushUserEvent:#value for:scrollBlock]. |
1748 | 1853 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
1854 |
! |
|
1855 |
||
1856 |
stopAutoScroll |
|
1857 |
"stop any autoScroll |
|
1858 |
" |
|
1859 |
autoScrollBlock notNil ifTrue:[ |
|
2265 | 1860 |
Processor removeTimedBlock:autoScrollBlock. |
1861 |
autoScrollBlock := nil. |
|
1862 |
self compressMotionEvents:true. |
|
1748 | 1863 |
]. |
1864 |
! ! |
|
1865 |
||
2644 | 1866 |
!ListModelView methodsFor:'selection'! |
1867 |
||
1868 |
hasSelection |
|
5683 | 1869 |
"by default, false is returned here (redefined in SelectionInListModelView)" |
1870 |
||
2644 | 1871 |
^ false |
1872 |
! ! |
|
1873 |
||
2352 | 1874 |
!ListModelView::Renderer class methodsFor:'documentation'! |
1875 |
||
1876 |
documentation |
|
1877 |
" |
|
1878 |
prepared for ListItemRenderer |
|
1879 |
.... SelectionItemRenderer ... |
|
1880 |
||
1881 |
goal: |
|
3728 | 1882 |
allow the user to redefine the display operation and the dimesion queries |
2352 | 1883 |
" |
1884 |
! ! |
|
1885 |
||
1886 |
!ListModelView::Renderer class methodsFor:'instance creation'! |
|
1887 |
||
1888 |
forView:aView |
|
1889 |
|renderer| |
|
1890 |
||
1891 |
renderer := self basicNew initialize. |
|
1892 |
renderer forView:aView. |
|
1893 |
^ renderer |
|
1894 |
! ! |
|
1895 |
||
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1896 |
!ListModelView::Renderer methodsFor:'accessing-look'! |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1897 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1898 |
showItemInAdditionToColumns |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1899 |
"raise an error: must be redefined in concrete subclass(es)" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1900 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1901 |
^ true "/There are no columns!!" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1902 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1903 |
"Modified: / 24-04-2013 / 13:27:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1904 |
! ! |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
1905 |
|
2640 | 1906 |
!ListModelView::Renderer methodsFor:'change & update'! |
1907 |
||
1908 |
listWillChange |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1909 |
"called before the list changed, clear caches etc. |
2640 | 1910 |
here nothing is done |
1911 |
" |
|
2644 | 1912 |
! |
1913 |
||
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1914 |
sizeChanged:how |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1915 |
"Called when size of the corresponding view has changed." |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1916 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1917 |
"Created: / 17-04-2013 / 11:42:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1918 |
! |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1919 |
|
2644 | 1920 |
withinUpdateFromListDo:aBlock |
1921 |
"handle an update from the list |
|
1922 |
" |
|
1923 |
aBlock value |
|
2640 | 1924 |
! ! |
1925 |
||
2352 | 1926 |
!ListModelView::Renderer methodsFor:'displaying'! |
1927 |
||
1928 |
display:anItem atX:xLeft y:yTop lineHeight:h |
|
4703 | 1929 |
"display the item on the view" |
1930 |
||
1931 |
"/ obsolete - for backward compatibility |
|
1932 |
self display:anItem atX:xLeft y:yTop lineHeight:h isHighlightedAsSelected:false |
|
1933 |
! |
|
1934 |
||
1935 |
display:anItem atX:xLeft y:yTop lineHeight:h isHighlightedAsSelected:isHighlightedAsSelected |
|
2352 | 1936 |
"display the item on the view |
1937 |
" |
|
4707 | 1938 |
|x0 y0 label labelShown| |
2352 | 1939 |
|
1940 |
x0 := xLeft. |
|
1941 |
y0 := yTop. |
|
1942 |
||
1943 |
anItem isHierarchicalItem ifTrue:[ |
|
4752 | 1944 |
(anItem class whichClassIncludesSelector:#displayOn:x:y:h:) ~~ AbstractHierarchicalItem ifTrue:[ |
4720 | 1945 |
"/ it has a redefined displayOn method. |
4706 | 1946 |
Transcript showCR:'please define #displayOn:x:y:h:isHighlightedAsSelected: in ',anItem class name. |
1947 |
anItem displayOn:view x:x0 y:y0 h:h |
|
1948 |
] ifFalse:[ |
|
1949 |
anItem displayOn:view x:x0 y:y0 h:h isHighlightedAsSelected:isHighlightedAsSelected |
|
1950 |
]. |
|
2352 | 1951 |
] ifFalse:[ |
4703 | 1952 |
anItem isNil ifTrue:[^ self]. |
1953 |
||
1954 |
y0 := y0 - (((self heightFor:anItem) + 1 - h) // 2). |
|
1955 |
label := anItem. |
|
1956 |
||
1957 |
label isImageOrForm ifFalse:[ |
|
1958 |
label isNumber ifTrue:[ |
|
1959 |
label := label printString |
|
1960 |
]. |
|
1961 |
y0 := y0 + view font ascent |
|
1962 |
]. |
|
4707 | 1963 |
labelShown := label. |
1964 |
label isText ifTrue:[ |
|
1965 |
isHighlightedAsSelected ifTrue:[ |
|
1966 |
(label hasChangeOfEmphasis) ifTrue:[ |
|
1967 |
labelShown := Text string:label string emphasisCollection:label emphasis asArray. |
|
1968 |
labelShown emphasisAllRemove:#color. |
|
1969 |
]. |
|
1970 |
]. |
|
1971 |
]. |
|
1972 |
labelShown displayOn:view x:x0 y:y0 |
|
2352 | 1973 |
]. |
2644 | 1974 |
! |
1975 |
||
1976 |
postRedrawX:damageX y:yStartOrYDamage w:damageWidth from:startOrNil to:stopOrNil |
|
1977 |
"called after redraw of the items in range from start to stop is done; |
|
1978 |
if no items are damaged, start and stop is set to nil. |
|
1979 |
" |
|
1980 |
! |
|
1981 |
||
1982 |
validateDrawableItemsFrom:start to:stop |
|
1983 |
"called before drawing items from start to stop; if the method returns false |
|
1984 |
nothing will be drawn and a invalidate is pushed on the event queue. |
|
1985 |
On default true is returned. |
|
1986 |
" |
|
1987 |
^ true |
|
2352 | 1988 |
! ! |
1989 |
||
1990 |
!ListModelView::Renderer methodsFor:'instance creation'! |
|
1991 |
||
1992 |
forView:aView |
|
1993 |
view := aView. |
|
2644 | 1994 |
view shown ifTrue:[ self mapped ]. |
2643 | 1995 |
! |
1996 |
||
1997 |
mapped |
|
1998 |
"called if the view is mapped; can be redefined by subclass |
|
1999 |
" |
|
2352 | 2000 |
! ! |
2001 |
||
2002 |
!ListModelView::Renderer methodsFor:'queries-dimensions'! |
|
2003 |
||
2004 |
heightFor:anItem |
|
2005 |
"returns the height of an item on the view |
|
2006 |
" |
|
2007 |
^ anItem heightOn:view |
|
2008 |
! |
|
2009 |
||
2643 | 2010 |
maxItemWidthOrNil |
2011 |
"returns the maximum item width for drawing or nil |
|
2012 |
if unspecified (the default); used for cliping |
|
2013 |
" |
|
2014 |
^ nil |
|
2015 |
! |
|
2016 |
||
2352 | 2017 |
widthFor:anItem |
2018 |
"returns the width of an item on the view |
|
2019 |
" |
|
2020 |
^ anItem widthOn:view |
|
2644 | 2021 |
! |
2022 |
||
2023 |
widthOfWidestLineBetween:firstLine and:lastLine |
|
2024 |
"returns the width of the longest line in pixels in a range; if the rendere |
|
2025 |
cannot compute the width, nil is returned (the default). |
|
2026 |
" |
|
2027 |
^ nil |
|
2352 | 2028 |
! ! |
2029 |
||
3717 | 2030 |
!ListModelView::TableRenderer class methodsFor:'defaults'! |
2031 |
||
2032 |
dragCursor |
|
2033 |
"returns the cursor used to highliggt the drag can start operation |
|
2034 |
" |
|
2035 |
^ Cursor leftRightArrow |
|
2036 |
! |
|
2037 |
||
2038 |
separatorOneDColor |
|
2039 |
"answer the color used for drawing separators" |
|
2040 |
||
4645 | 2041 |
^ Color lightGray |
3717 | 2042 |
! ! |
2043 |
||
2044 |
!ListModelView::TableRenderer methodsFor:'accessing'! |
|
2045 |
||
2046 |
columnDescriptors:aSeqOfColumnSpecs |
|
2047 |
"setup column descriptions for a sequence of DataSetColumnSpec's but still keep |
|
2048 |
the receiver which provides the selectors called by the DataSetColumnSpec. |
|
2049 |
||
2050 |
If the receiver is nil, the item into the list is invoked" |
|
2051 |
||
2052 |
self columnDescriptors:aSeqOfColumnSpecs receiver:receiver. |
|
2053 |
! |
|
2054 |
||
2055 |
columnDescriptors:aSeqOfColumnSpecs receiver:aReceiver |
|
2056 |
"setup column descriptions for a sequence of DataSetColumnSpec's and the |
|
2057 |
receiver which provides the selectors called by the DataSetColumnSpec. |
|
2058 |
||
2059 |
If the receiver is nil, the item into the list is invoked" |
|
2060 |
||
2061 |
receiver := aReceiver. |
|
2062 |
||
2063 |
minimumRequiredColumnHeight := 0. |
|
2064 |
||
2065 |
aSeqOfColumnSpecs size == 0 ifTrue:[ |
|
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2066 |
columnDescriptors := #(). |
3717 | 2067 |
] ifFalse:[ |
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2068 |
columnDescriptors := aSeqOfColumnSpecs collect:[:aColumnSpec| |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2069 |
ColumnDescriptor dataSetColumnSpec:aColumnSpec |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2070 |
]. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2071 |
columnDescriptors keysAndValuesDo:[:colNr :spec| |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2072 |
spec columnNumber:colNr. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2073 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2074 |
minimumRequiredColumnHeight := |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2075 |
minimumRequiredColumnHeight max:(spec minimumRequiredColumnHeight). |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2076 |
]. |
3717 | 2077 |
]. |
2078 |
hasFixedItemWidth := attributes at:#hasFixedItemWidth ifAbsent:[false]. |
|
2079 |
||
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2080 |
self initializeSplitbars. |
3717 | 2081 |
self splitbarsChanged |
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2082 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2083 |
"Modified: / 24-04-2013 / 13:32:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2084 |
! |
2085 |
||
2086 |
numberOfColumns |
|
2087 |
"answer the numbers of columns excluding the items row" |
|
2088 |
||
2089 |
^ columnDescriptors size |
|
4204
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2090 |
! |
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2091 |
|
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2092 |
xSplitbars |
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2093 |
^ xSplitbars |
3717 | 2094 |
! ! |
2095 |
||
2096 |
!ListModelView::TableRenderer methodsFor:'accessing-look'! |
|
2097 |
||
2098 |
defaultWidthForItem |
|
2099 |
"answer the default witdth of the item before the first column" |
|
2100 |
||
2101 |
^ attributes at:#defaultWidthForItem ifAbsent:[ 100 ]. |
|
2102 |
! |
|
2103 |
||
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2104 |
defaultWidthForItem:anIntegerOrFloat |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2105 |
"Set the default witdth of the item before the first column. |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2106 |
If `anIntegerOrFloat` is |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2107 |
- an integer then the width is absolute width in pixels |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2108 |
- a float in <0.0, 1,1> then the width is percentage |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2109 |
of view's width |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2110 |
" |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2111 |
anIntegerOrFloat isFloat ifTrue:[ |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2112 |
self assert: (anIntegerOrFloat between: 0.0 and: 1.0) |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2113 |
]. |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2114 |
^ attributes at:#defaultWidthForItem put:anIntegerOrFloat. |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2115 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2116 |
"Modified: / 12-08-2013 / 12:20:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2117 |
! |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2118 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2119 |
defaultWidthForItemInPixels |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2120 |
"Answer the default witdth of the item before the first column in pixels" |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2121 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2122 |
| w | |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2123 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2124 |
w := self defaultWidthForItem. |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2125 |
w isFloat ifTrue:[ |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2126 |
w := (view width * w) rounded. |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2127 |
]. |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2128 |
^ w |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2129 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2130 |
"Created: / 12-08-2013 / 12:16:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2131 |
! |
2132 |
||
2133 |
noAutoResizeForRowOfItems |
|
2134 |
"the first row which keeps the items are not automaticaly resized |
|
2135 |
when width of items changed" |
|
2136 |
||
2137 |
hasFixedItemWidth := true. |
|
2138 |
attributes at:#hasFixedItemWidth put:true. |
|
2139 |
! |
|
2140 |
||
2141 |
separatorOneDColor |
|
2142 |
"answer the color used for drawing separators" |
|
2143 |
||
2144 |
separatorOneDColor isNil ifTrue:[ |
|
3728 | 2145 |
separatorOneDColor := self class separatorOneDColor. |
2146 |
||
2147 |
(view notNil and:[view realized]) ifTrue:[ |
|
2148 |
separatorOneDColor := separatorOneDColor onDevice:(view device). |
|
2149 |
]. |
|
3717 | 2150 |
]. |
2151 |
^ separatorOneDColor |
|
2152 |
! |
|
2153 |
||
2154 |
showHorizontalSeparators |
|
2155 |
"answer true if horizontal separators are drawn" |
|
2156 |
||
2157 |
^ attributes at:#showHorizontalSeparators ifAbsent:[ true ]. |
|
2158 |
! |
|
2159 |
||
2160 |
showHorizontalSeparators:aBoolean |
|
2161 |
"set true if horizontal separators are drawn" |
|
2162 |
||
2163 |
attributes at:#showHorizontalSeparators put:aBoolean. |
|
2164 |
! |
|
2165 |
||
2166 |
showHorizontalSeparatorsForItem |
|
2167 |
"answer true if horizontal separators is drawn for the item row" |
|
2168 |
||
2169 |
^ attributes at:#showHorizontalSeparatorsForItem ifAbsent:[ true ]. |
|
2170 |
! |
|
2171 |
||
2172 |
showHorizontalSeparatorsForItem:aBoolean |
|
2173 |
"set true if horizontal separators is drawn for the item row" |
|
2174 |
||
2175 |
attributes at:#showHorizontalSeparatorsForItem put:aBoolean. |
|
2176 |
! |
|
2177 |
||
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2178 |
showItemInAdditionToColumns |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2179 |
"Return, whether the item itseld should be shown in addition to |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2180 |
columns (default)" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2181 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2182 |
^attributes at:#showVerticalSplitbarsBelowContents ifAbsent:[ true ] |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2183 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2184 |
"Created: / 24-04-2013 / 13:26:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2185 |
! |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2186 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2187 |
showItemInAdditionToColumns:aBoolean |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2188 |
"If set to troe, the implicit forst column is shown (old behaviour). |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2189 |
When false, only column are shown" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2190 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2191 |
| old | |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2192 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2193 |
old := self showItemInAdditionToColumns. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2194 |
old == self ifTrue:[ ^ self ]. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2195 |
attributes at:#showVerticalSplitbarsBelowContents put:aBoolean. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2196 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2197 |
"Created: / 24-04-2013 / 13:24:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2198 |
! |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2199 |
|
3717 | 2200 |
showVerticalSplitbars |
2201 |
"answer true if vertical separators are drawn" |
|
2202 |
||
2203 |
^ attributes at:#showVerticalSplitbars ifAbsent:[ true ]. |
|
2204 |
! |
|
2205 |
||
2206 |
showVerticalSplitbars:aBoolean |
|
2207 |
"set true if vertical separators are drawn" |
|
2208 |
||
2209 |
attributes at:#showVerticalSplitbars put:aBoolean. |
|
2210 |
! |
|
2211 |
||
2212 |
showVerticalSplitbarsBelowContents |
|
2213 |
"answer true if the vertical separators are drawn below last row" |
|
2214 |
||
2215 |
^ attributes at:#showVerticalSplitbarsBelowContents ifAbsent:[ false ]. |
|
2216 |
! |
|
2217 |
||
2218 |
showVerticalSplitbarsBelowContents:aBoolean |
|
2219 |
"set true if the vertical separators are drawn below last row" |
|
2220 |
||
2221 |
attributes at:#showVerticalSplitbarsBelowContents put:aBoolean. |
|
2222 |
! |
|
2223 |
||
2224 |
splitbarInset |
|
2225 |
"returns the horizontal left and right inset of the splitbar" |
|
2226 |
||
2227 |
^ 2 |
|
2228 |
! |
|
2229 |
||
2230 |
textStartLeft |
|
2231 |
"used when drawing the last separator; |
|
2232 |
workaround when drawing the selection frame" |
|
2233 |
||
2234 |
^ 2 |
|
2235 |
! ! |
|
2236 |
||
2237 |
!ListModelView::TableRenderer methodsFor:'actions'! |
|
2238 |
||
2239 |
moveSplitbarAt:aSepIndex toAbsoluteX:x |
|
2240 |
"move the position of the separator at an index to absolute position x; |
|
2241 |
used to drag splitbars" |
|
2242 |
||
2243 |
|xOld xNew xPrv deltaX xAbsoluteOfFirstSplitbar| |
|
2244 |
||
2245 |
aSepIndex == 1 ifTrue:[ |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2246 |
hasFixedItemWidth := true. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2247 |
xPrv := view margin. |
3717 | 2248 |
] ifFalse:[ |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2249 |
xPrv := xSplitbars at:(aSepIndex - 1). |
3717 | 2250 |
]. |
2251 |
||
2252 |
aSepIndex == 1 ifTrue:[ |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2253 |
hasFixedItemWidth := true. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2254 |
xPrv := view margin. |
3717 | 2255 |
] ifFalse:[ |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2256 |
xPrv := xSplitbars at:(aSepIndex - 1). |
3717 | 2257 |
]. |
2258 |
xOld := xSplitbars at:aSepIndex. |
|
2259 |
xNew := x max:xPrv. |
|
2260 |
||
2261 |
deltaX := xNew - xOld. |
|
2262 |
deltaX = 0 ifTrue:[ ^ self ]. |
|
2263 |
||
2264 |
xAbsoluteOfFirstSplitbar := xSplitbars at:1. |
|
2265 |
||
2266 |
xSplitbars from:aSepIndex keysAndValuesDo:[:sepIdx :sepX| |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2267 |
xSplitbars at:sepIdx put:(sepX + deltaX). |
3717 | 2268 |
]. |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2269 |
aSepIndex ~~ 1 ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2270 |
(columnDescriptors at: aSepIndex - 1) width: (xSplitbars at: aSepIndex) - (xSplitbars at: aSepIndex - 1) - (self splitbarInset * 2). |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2271 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2272 |
|
3717 | 2273 |
view setWidthOfContents:(xSplitbars last). |
2274 |
||
2275 |
view shown ifTrue:[ |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2276 |
|damage width height orgX| |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2277 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2278 |
view windowGroup processRealExposeEventsFor:self. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2279 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2280 |
width := view width. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2281 |
height := view height. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2282 |
orgX := view viewOrigin x. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2283 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2284 |
xNew := ((xNew - orgX) max:0) min:width. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2285 |
xOld := ((xOld - orgX) max:0) min:width. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2286 |
xPrv := ((xPrv - orgX) max:0) min:width. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2287 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2288 |
xOld > xNew ifTrue:[ "/ <- copy to left |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2289 |
deltaX := xOld - xNew. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2290 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2291 |
view copyFrom:view x:xOld y:0 toX:xNew y:0 |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2292 |
width:(width - xOld) height:height. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2293 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2294 |
damage := Rectangle left:(width - deltaX) top:0 width:deltaX height:height. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2295 |
view invalidateDeviceRectangle:damage repairNow:false. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2296 |
] ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2297 |
xOld < xNew ifTrue:[ "/ -> copy to right |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2298 |
view copyFrom:view x:xOld y:0 toX:xNew y:0 |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2299 |
width:(width - xNew) height:height. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2300 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2301 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2302 |
xNew > xPrv ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2303 |
"/ should not invalidate the items display range..." |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2304 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2305 |
xAbsoluteOfFirstSplitbar := xAbsoluteOfFirstSplitbar - self splitbarInset. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2306 |
xPrv := (xPrv max:xAbsoluteOfFirstSplitbar). |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2307 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2308 |
xNew > xPrv ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2309 |
damage := Rectangle left:xPrv top:0 width:(xNew -xPrv) height:height. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2310 |
view invalidateDeviceRectangle:damage repairNow:false. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2311 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2312 |
]. |
3717 | 2313 |
]. |
2314 |
view contentsChanged. |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2315 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2316 |
"Modified: / 07-05-2013 / 20:55:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2317 |
! ! |
2318 |
||
2319 |
!ListModelView::TableRenderer methodsFor:'change & update'! |
|
2320 |
||
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2321 |
sizeChanged:how |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2322 |
view sensor pushUserEvent:#sizeChangedDelayed: for:self withArgument:how |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2323 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2324 |
"Created: / 07-05-2013 / 18:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2325 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2326 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2327 |
sizeChangedDelayed:how |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2328 |
self initializeSplitbars. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2329 |
self splitbarsChanged. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2330 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2331 |
"Created: / 07-05-2013 / 18:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2332 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2333 |
|
3717 | 2334 |
splitbarsChanged |
2335 |
"called if the splitbars has changed; recompute the width of contents" |
|
2336 |
||
2337 |
view notNil ifTrue:[ |
|
3728 | 2338 |
|newWidth oldWidth| |
2339 |
||
2340 |
oldWidth := view getWidthOfContents. |
|
2341 |
||
2342 |
oldWidth notNil ifTrue:[ |
|
2343 |
newWidth := xSplitbars last. |
|
2344 |
||
2345 |
newWidth ~= oldWidth ifTrue:[ |
|
2346 |
view setWidthOfContents:newWidth. |
|
2347 |
view contentsChanged. |
|
2348 |
]. |
|
2349 |
view invalidate. |
|
2350 |
]. |
|
3717 | 2351 |
]. |
2352 |
! |
|
2353 |
||
2354 |
withinUpdateFromListDo:aBlock |
|
2355 |
"handle an change & update within the view" |
|
2356 |
||
2357 |
|xAbs| |
|
2358 |
||
2359 |
xAbs := xSplitbars last. |
|
2360 |
super withinUpdateFromListDo:aBlock. |
|
2361 |
||
2362 |
xAbs ~~ xSplitbars last ifTrue:[ |
|
3728 | 2363 |
self splitbarsChanged |
3717 | 2364 |
]. |
2365 |
! ! |
|
2366 |
||
2367 |
!ListModelView::TableRenderer methodsFor:'displaying'! |
|
2368 |
||
2369 |
drawColumnsFrom:start to:stop x:xDmg y:yStart w:wDmg |
|
2370 |
"draw columns from start to stop. |
|
2371 |
if the start/stop index is nil, than no row is affected by the damage." |
|
2372 |
||
2373 |
|xNxt xMax xTrs clip y0 y1 x0 x1 hgFgColor hgBgColor fgColor bgColor colInset |
|
3722 | 2374 |
shownSelected numSplitbars| |
2375 |
||
2376 |
start isNil ifTrue:[^ self]. |
|
2377 |
numSplitbars := xSplitbars size. |
|
2378 |
numSplitbars > 1 ifFalse:[^ self]. |
|
3717 | 2379 |
|
2380 |
xTrs := view viewOrigin x. |
|
2381 |
xMax := xDmg + wDmg. |
|
2382 |
xNxt := xSplitbars first - xTrs. |
|
2383 |
||
2384 |
xNxt >= xMax ifTrue:[^ self]. |
|
2385 |
||
2386 |
view hasSelection ifTrue:[ |
|
3909 | 2387 |
hgFgColor := view hilightForegroundColor. |
2388 |
hgBgColor := view hilightBackgroundColor. |
|
3717 | 2389 |
]. |
3728 | 2390 |
fgColor := view foregroundColor. |
3717 | 2391 |
bgColor := view backgroundColor. |
4478 | 2392 |
clip := view clippingBoundsOrNil. |
3717 | 2393 |
|
2394 |
clip isNil ifTrue:[ |
|
3909 | 2395 |
clip := Rectangle left:xDmg top:yStart width:wDmg height:(view height - yStart). |
3717 | 2396 |
]. |
2397 |
colInset := self splitbarInset. |
|
2398 |
||
3722 | 2399 |
2 to:numSplitbars do:[:anIndex| |
3909 | 2400 |
|clipLft clipRgt colWdth colDesc| |
2401 |
||
2402 |
xNxt < xMax ifFalse:[^ self]. |
|
2403 |
||
2404 |
x0 := xNxt. |
|
2405 |
xNxt := (xSplitbars at:anIndex) - xTrs. |
|
2406 |
x1 := xNxt. |
|
2407 |
||
2408 |
"/ workaround due to drawing the selection frame |
|
2409 |
anIndex == numSplitbars ifTrue:[ x1 := x1 + self textStartLeft ]. |
|
2410 |
||
2411 |
colDesc := columnDescriptors at:(anIndex - 1) ifAbsent:[ ^ self ]. "/ can give up... |
|
2412 |
clipLft := x0 max:xDmg. |
|
2413 |
clipRgt := x1 min:xMax. |
|
2414 |
colWdth := x1 - x0. |
|
2415 |
||
2416 |
(colWdth > 2 and:[clipLft < clipRgt]) ifTrue:[ |
|
2417 |
clip := clip copy. |
|
2418 |
clip setLeft:clipLft. |
|
2419 |
clip right:clipRgt. |
|
5406 | 2420 |
view clippingBounds:clip. |
3909 | 2421 |
y1 := yStart. |
2422 |
||
2423 |
start to:stop do:[:aRowNr| |
|
2424 |
|recv| |
|
2425 |
||
2426 |
y0 := y1. |
|
2427 |
y1 := view yVisibleOfLine:(aRowNr + 1). |
|
2428 |
||
2429 |
recv := receiver. |
|
2430 |
recv isNil ifTrue:[ recv := view at:aRowNr ifAbsent:nil ]. |
|
2431 |
||
2432 |
recv notNil ifTrue:[ |
|
2433 |
(hgFgColor notNil and:[view isInSelection:aRowNr]) ifTrue:[ |
|
2434 |
shownSelected := true. |
|
2435 |
view paint:hgFgColor on:hgBgColor |
|
2436 |
] ifFalse:[ |
|
2437 |
shownSelected := false. |
|
2438 |
view paint:fgColor on:bgColor. |
|
2439 |
]. |
|
2440 |
colDesc |
|
2441 |
drawRowAt:aRowNr |
|
2442 |
shownSelected:shownSelected |
|
2443 |
receiver:recv |
|
2444 |
x:x0 + colInset |
|
2445 |
y:y0 |
|
2446 |
w:colWdth - colInset - colInset |
|
2447 |
h:(y1 - y0) on:view. |
|
2448 |
]. |
|
2449 |
]. |
|
2450 |
]. |
|
3717 | 2451 |
]. |
3909 | 2452 |
|
2453 |
"Modified: / 16-06-2010 / 16:34:32 / cg" |
|
3717 | 2454 |
! |
2455 |
||
2456 |
drawHorizontalSeparatorsX:x y:y w:w from:start to:stop |
|
2457 |
"draw horizontal seperators from start to stop. |
|
2458 |
if the start/stop index is nil, than no row is affected by the damage." |
|
2459 |
||
2460 |
|x1 ySep clipRec x0| |
|
2461 |
||
2462 |
start isNil ifTrue:[ ^ self ]. |
|
2463 |
||
2464 |
"/ workaround due to drawing the selection frame |
|
2465 |
x1 := self xVisibleOfLastSplitbar + self textStartLeft. |
|
2466 |
||
2467 |
x1 := x1 min:(x + w). |
|
2468 |
x1 <= x ifTrue:[^ self]. |
|
2469 |
||
2470 |
x0 := x. |
|
2471 |
||
2472 |
self showHorizontalSeparatorsForItem ifFalse:[ |
|
5406 | 2473 |
x0 := x0 max:(self xVisibleOfSplitbarAt:1). |
2474 |
x1 <= x0 ifTrue:[^ self]. |
|
3717 | 2475 |
]. |
2476 |
clipRec := Rectangle left:x0 top:0 right:x1 bottom:(view height). |
|
2477 |
||
5406 | 2478 |
view clippingBounds:clipRec. |
3717 | 2479 |
view paint:(self separatorOneDColor). |
2480 |
||
2481 |
start to:stop do:[:aRowNr| |
|
5406 | 2482 |
ySep := (view yVisibleOfLine:(aRowNr + 1)) - 1. |
2483 |
view displayLineFromX:x0 y:ySep toX:x1 y:ySep. |
|
3717 | 2484 |
]. |
2485 |
! |
|
2486 |
||
2487 |
drawVerticalSplitbarsX:x0 y:y0 w:w from:start to:stop |
|
2488 |
"draw vertical splitbars" |
|
2489 |
||
2490 |
|x x1 vX y1 clipRec nrOfSep| |
|
2491 |
||
2492 |
nrOfSep := xSplitbars size. |
|
2493 |
nrOfSep == 0 ifTrue:[^ self]. |
|
2494 |
||
2495 |
"/ workaround for textStartTop |
|
2496 |
||
2497 |
y1 := view height. |
|
2498 |
||
2499 |
self showVerticalSplitbarsBelowContents ifFalse:[ |
|
5406 | 2500 |
stop isNil ifTrue:[^ self]. |
2501 |
||
2502 |
y1 := y1 min:(view yVisibleOfLine:(stop + 1)). |
|
2503 |
y1 <= y0 ifTrue:[ ^ self ]. |
|
3717 | 2504 |
]. |
2505 |
x1 := x0 + w. |
|
2506 |
vX := view viewOrigin x. |
|
2507 |
||
2508 |
xSplitbars keysAndValuesDo:[:anIndex :physY| |
|
5406 | 2509 |
(self showVerticalSplitbarAt:anIndex) ifTrue:[ |
2510 |
x := physY - vX. |
|
2511 |
x > x1 ifTrue:[^ self]. "/ can giveup - behind max x1 |
|
2512 |
||
2513 |
anIndex == nrOfSep ifTrue:[ |
|
2514 |
"/ workaround due to drawing the selection frame |
|
2515 |
x := x + self textStartLeft |
|
2516 |
]. |
|
2517 |
x >= x0 ifTrue:[ |
|
2518 |
clipRec isNil ifTrue:[ |
|
2519 |
"/ first time to setup clipping and colors |
|
2520 |
||
2521 |
clipRec := Rectangle left:x0 top:y0 right:x1 bottom:y1. |
|
2522 |
view clippingBounds:clipRec. |
|
2523 |
view paint:(self separatorOneDColor). |
|
2524 |
]. |
|
2525 |
view displayLineFromX:x y:y0 toX:x y:y1. |
|
2526 |
]. |
|
2527 |
]. |
|
3717 | 2528 |
]. |
2529 |
! |
|
2530 |
||
2531 |
postRedrawX:x y:y w:w from:start to:stop |
|
2532 |
"draw columns and than the splitbars" |
|
2533 |
||
2534 |
self drawColumnsFrom:start to:stop x:x y:y w:w. |
|
2535 |
||
2536 |
self showHorizontalSeparators ifTrue:[ |
|
3728 | 2537 |
self drawHorizontalSeparatorsX:x y:y w:w from:start to:stop. |
3717 | 2538 |
]. |
2539 |
self showVerticalSplitbars ifTrue:[ |
|
3728 | 2540 |
self drawVerticalSplitbarsX:x y:y w:w from:start to:stop. |
3717 | 2541 |
]. |
2542 |
! |
|
2543 |
||
2544 |
validateDrawableItemsFrom:start to:stop |
|
2545 |
"called before drawing the items in range from start to stop; the |
|
2546 |
renderer can perform some tests whether the draw operation might |
|
2547 |
fail; width, ... might change during draw. |
|
2548 |
If a test failed, the renderer should repair the failed test and |
|
2549 |
return false. In this case a full redraw is done. |
|
2550 |
On default true is returned." |
|
2551 |
||
2552 |
|xLastOld xLastNew| |
|
2553 |
||
2554 |
xLastOld := xSplitbars last. |
|
2555 |
xLastNew := self widthOfWidestLineBetween:start and:stop. |
|
2556 |
||
2557 |
xLastNew == xLastOld ifTrue:[^ true]. |
|
2558 |
||
2559 |
self splitbarsChanged. |
|
2560 |
^ false |
|
2561 |
! ! |
|
2562 |
||
2563 |
!ListModelView::TableRenderer methodsFor:'enumerating'! |
|
2564 |
||
3722 | 2565 |
columnDescriptorsDo:aOneArgBlock |
2566 |
columnDescriptors size > 0 ifTrue:[ |
|
3728 | 2567 |
columnDescriptors do:aOneArgBlock. |
3722 | 2568 |
]. |
2569 |
! |
|
2570 |
||
2571 |
columnDescriptorsKeysAndValuesDo:aTwoArgBlock |
|
2572 |
||
2573 |
columnDescriptors size > 0 ifTrue:[ |
|
3728 | 2574 |
columnDescriptors keysAndValuesDo:aTwoArgBlock. |
3722 | 2575 |
]. |
2576 |
! |
|
2577 |
||
3717 | 2578 |
xSplitbarsDo:aOneArgblock |
2579 |
"evaluate a block on each x splitbar position |
|
2580 |
" |
|
2581 |
^ xSplitbars do:aOneArgblock. |
|
2582 |
! |
|
2583 |
||
2584 |
xSplitbarsKeysAndValuesDo:aTwoArgblock |
|
2585 |
"evaluate a block on each x splitbar index and position |
|
2586 |
" |
|
2587 |
^ xSplitbars keysAndValuesDo:aTwoArgblock. |
|
2588 |
! ! |
|
2589 |
||
2590 |
!ListModelView::TableRenderer methodsFor:'event processing'! |
|
2591 |
||
2592 |
addEventHook |
|
2593 |
"add event hook to window group" |
|
2594 |
||
2595 |
|winGrp| |
|
2596 |
||
2597 |
view notNil ifTrue:[ |
|
3728 | 2598 |
winGrp := view windowGroup. |
2599 |
||
2600 |
winGrp notNil ifTrue:[ |
|
2601 |
view enableMotionEvents. |
|
2602 |
winGrp addPreEventHook:self. |
|
2603 |
]. |
|
3717 | 2604 |
]. |
2605 |
! |
|
2606 |
||
2607 |
processEvent:ev |
|
2608 |
"only handled if drag splitbar is enabled" |
|
2609 |
||
4168 | 2610 |
<resource: #keyboard (#Escape )> |
2611 |
||
3717 | 2612 |
ev isInputEvent ifFalse:[^ false]. |
2613 |
||
2614 |
dragOperation notNil ifTrue:[ |
|
3909 | 2615 |
dragOperation value:ev. |
2616 |
^ true |
|
3717 | 2617 |
]. |
2618 |
||
2619 |
(view shown |
|
2620 |
and:[ev view == view |
|
2621 |
and:[(ev isButtonPressEvent or:[ev isButtonMotionEvent]) |
|
3909 | 2622 |
and:[((ev button ~= 2) and:[ev button ~= #menu])]]]) ifTrue:[ |
2623 |
|splitBarColIndex colIndex phyX colX descr| |
|
2624 |
||
2625 |
splitBarColIndex := self xVisibleToSplitbar:(ev x). |
|
2626 |
||
2627 |
(splitBarColIndex > 0 and:[self showVerticalSplitbarsBelowContents not]) ifTrue:[ |
|
2628 |
"/ test whether y is below contents.... |
|
2629 |
ev y > (view heightOfContents - view viewOrigin y) ifTrue:[ |
|
2630 |
splitBarColIndex := 0 |
|
2631 |
]. |
|
2632 |
]. |
|
2633 |
||
2634 |
ev isButtonPressEvent ifTrue:[ |
|
2635 |
splitBarColIndex < 1 ifTrue:[ |
|
2636 |
"/ see if a title-column has been clicked on... |
|
2637 |
colIndex := self xAbsoluteToColumnIndex:(ev x). |
|
2638 |
(colIndex > 0 and:[colIndex <= columnDescriptors size]) ifTrue:[ |
|
2639 |
descr := columnDescriptors at:colIndex. |
|
2640 |
descr := descr dataSetColumnSpec. |
|
2641 |
descr isSortable ifTrue:[ |
|
2642 |
"/ see if clicked in the top-row; sort as appropriate... |
|
2643 |
self breakPoint:#todo. |
|
2644 |
]. |
|
2645 |
]. |
|
2646 |
^ false |
|
2647 |
]. |
|
2648 |
||
2649 |
colX := self xAbsoluteOfSplitbarAt:splitBarColIndex. |
|
2650 |
phyX := ev x. |
|
2651 |
||
2652 |
dragOperation := [:event| |
|
2653 |
event isKeyEvent ifTrue:[ |
|
2654 |
event rawKey == #Escape ifTrue:[ |
|
2655 |
dragOperation := nil. |
|
2656 |
self moveSplitbarAt:splitBarColIndex toAbsoluteX:colX. |
|
2657 |
]. |
|
2658 |
] ifFalse:[ |
|
2659 |
event isButtonPressEvent ifTrue:[ |
|
2660 |
dragOperation := nil. |
|
2661 |
self moveSplitbarAt:splitBarColIndex toAbsoluteX:colX. |
|
2662 |
]. |
|
2663 |
event isButtonReleaseEvent ifTrue:[ |
|
2664 |
dragOperation := nil. |
|
2665 |
]. |
|
2666 |
event isButtonMotionEvent ifTrue:[ |
|
2667 |
(view sensor hasExposeEventFor:nil) ifFalse:[ |
|
2668 |
self |
|
2669 |
moveSplitbarAt:splitBarColIndex |
|
2670 |
toAbsoluteX:(colX + (event x) - phyX). |
|
2671 |
]. |
|
2672 |
]. |
|
2673 |
]. |
|
2674 |
]. |
|
2675 |
^ true |
|
2676 |
]. |
|
2677 |
||
2678 |
splitBarColIndex == 0 ifTrue:[ |
|
2679 |
savedCursor notNil ifTrue:[ |
|
2680 |
view cursor:savedCursor. |
|
2681 |
savedCursor := nil. |
|
2682 |
]. |
|
2683 |
] ifFalse:[ |
|
2684 |
savedCursor isNil ifTrue:[ |
|
2685 |
savedCursor := view cursor. |
|
2686 |
view cursor:dragCursor. |
|
2687 |
]. |
|
2688 |
]. |
|
3717 | 2689 |
]. |
2690 |
^ false |
|
3909 | 2691 |
|
2692 |
"Modified: / 16-06-2010 / 16:35:41 / cg" |
|
3717 | 2693 |
! |
2694 |
||
2695 |
removeEventHook |
|
2696 |
"release my event hook" |
|
2697 |
||
2698 |
|winGrp| |
|
2699 |
||
2700 |
view notNil ifTrue:[ |
|
3728 | 2701 |
winGrp := view windowGroup. |
2702 |
winGrp notNil ifTrue:[ winGrp removePreEventHook:self ]. |
|
3717 | 2703 |
]. |
2704 |
! ! |
|
2705 |
||
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2706 |
!ListModelView::TableRenderer methodsFor:'initialization'! |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2707 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2708 |
initializeSplitbars |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2709 |
| xInset numCols xOffset widths | |
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2710 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2711 |
xInset := 2 * self splitbarInset. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2712 |
numCols := columnDescriptors size. |
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2713 |
xOffset := self showItemInAdditionToColumns ifTrue:[self defaultWidthForItemInPixels] ifFalse:[0]. |
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2714 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2715 |
xSplitbars := Array new:(numCols + 1). |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2716 |
xSplitbars at:1 put:xOffset. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2717 |
|
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2718 |
widths := self computeColumnWidthsWithXOffset: xOffset . |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2719 |
|
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2720 |
1 to:numCols do:[:aColNr| |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2721 |
xOffset := xOffset + xInset + (widths at: aColNr). |
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2722 |
xSplitbars at:(aColNr + 1) put:xOffset. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2723 |
]. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2724 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2725 |
"Created: / 24-04-2013 / 13:32:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2726 |
"Modified: / 12-08-2013 / 12:16:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2727 |
! ! |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2728 |
|
3717 | 2729 |
!ListModelView::TableRenderer methodsFor:'instance creation'! |
2730 |
||
2731 |
forView:aView |
|
2732 |
"setup instance for a view; |
|
2733 |
setup my default columnDescription" |
|
2734 |
||
2735 |
attributes isNil ifTrue:[ |
|
3728 | 2736 |
attributes := IdentityDictionary new. |
3717 | 2737 |
]. |
2738 |
self columnDescriptors:nil. |
|
2739 |
super forView:aView. |
|
2740 |
! |
|
2741 |
||
2742 |
mapped |
|
2743 |
"install event hook and enable motion events |
|
2744 |
" |
|
2745 |
view notNil ifTrue:[ |
|
3728 | 2746 |
dragCursor isNil ifTrue:[ |
2747 |
dragCursor := self class dragCursor onDevice:(view device). |
|
2748 |
]. |
|
2749 |
separatorOneDColor notNil ifTrue:[ |
|
2750 |
separatorOneDColor := separatorOneDColor onDevice:(view device). |
|
2751 |
]. |
|
2752 |
self isDragEnabled ifTrue:[ self addEventHook ]. |
|
3717 | 2753 |
]. |
2754 |
! |
|
2755 |
||
2756 |
release |
|
2757 |
"release event hook |
|
2758 |
" |
|
2759 |
self removeEventHook. |
|
2760 |
super release. |
|
2761 |
! ! |
|
2762 |
||
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2763 |
!ListModelView::TableRenderer methodsFor:'private'! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2764 |
|
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2765 |
computeColumnWidthsWithXOffset: xoffset |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2766 |
| done widthsFixed widths viewW remainingW nCols flexSum flexUnit | |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2767 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2768 |
done := false. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2769 |
nCols := columnDescriptors size. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2770 |
nCols == 0 ifTrue:[ ^#() ]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2771 |
widthsFixed := Array new: nCols. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2772 |
widths := Array new: nCols. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2773 |
viewW := view width - |
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2774 |
(xoffset) - |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2775 |
(self splitbarInset * nCols * 2) - |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2776 |
(nCols) "splitbar width". |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2777 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2778 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2779 |
[ done ] whileFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2780 |
done := true. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2781 |
1 to: nCols do:[:c | |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2782 |
widths at: c put: (widthsFixed at: c) ? ((columnDescriptors at: c) width ? (columnDescriptors at: c) widthSpec) |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2783 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2784 |
remainingW := viewW. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2785 |
flexSum := 0.0. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2786 |
1 to: nCols do:[:c | | ws | |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2787 |
(ws := widths at: c) isInteger ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2788 |
remainingW := remainingW - ws. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2789 |
widthsFixed at: c put:ws. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2790 |
] ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2791 |
ws isFloat ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2792 |
flexSum := flexSum + ws. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2793 |
] |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2794 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2795 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2796 |
remainingW := remainingW max: 0. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2797 |
"/ Now, distribute remaining space to columns according their flex widths |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2798 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2799 |
flexSum > 0 ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2800 |
flexUnit := remainingW / flexSum. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2801 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2802 |
1 to: nCols do:[:c | | wflex wmin w | |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2803 |
(wflex := widths at: c) isFloat ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2804 |
w := (flexUnit * wflex) floor. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2805 |
wmin := (columnDescriptors at:c) widthMin. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2806 |
w < wmin ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2807 |
widthsFixed at: c put: wmin. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2808 |
done := false. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2809 |
] ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2810 |
widths at: c put: w. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2811 |
] |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2812 |
] |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2813 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2814 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2815 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2816 |
^widths |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2817 |
|
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2818 |
"Created: / 12-08-2013 / 12:14:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2819 |
! ! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2820 |
|
3717 | 2821 |
!ListModelView::TableRenderer methodsFor:'private accessing'! |
2822 |
||
2823 |
columnAlignmentAt:aColNr |
|
2824 |
^ (columnDescriptors at:aColNr) alignment |
|
2825 |
! |
|
2826 |
||
2827 |
defaultColumnWidthAt:aColIndex |
|
2828 |
^ (columnDescriptors at:aColIndex) defaultColumnWidth |
|
2829 |
! |
|
2830 |
||
2831 |
showVerticalSplitbarAt:aColIndex |
|
3728 | 2832 |
aColIndex > 1 ifTrue:[ |
2833 |
^ (columnDescriptors at:(aColIndex - 1)) showVerticalSplitbar |
|
3717 | 2834 |
]. |
2835 |
^ true |
|
2836 |
! ! |
|
2837 |
||
2838 |
!ListModelView::TableRenderer methodsFor:'queries-behavior'! |
|
2839 |
||
2840 |
isDragEnabled |
|
2841 |
"answer true if drag of separators is enabled" |
|
2842 |
||
2843 |
^ attributes at:#isDragEnabled ifAbsent:[ true ]. |
|
2844 |
! |
|
2845 |
||
2846 |
isDragEnabled:aBoolean |
|
2847 |
"answer true if drag of separators is enabled" |
|
2848 |
||
2849 |
attributes at:#isDragEnabled put:aBoolean. |
|
2850 |
||
2851 |
aBoolean ifTrue:[ self addEventHook ] |
|
3728 | 2852 |
ifFalse:[ self removeEventHook ]. |
3717 | 2853 |
! ! |
2854 |
||
2855 |
!ListModelView::TableRenderer methodsFor:'queries-dimensions'! |
|
2856 |
||
4198 | 2857 |
boundingBoxForCellAtXAbsolute:x yAbsolute:y |
2858 |
||
2859 |
|xNxt xTrs y0 y1 x0 x1 colInset colNr rowNr numSplitbars| |
|
2860 |
||
2861 |
numSplitbars := xSplitbars size. |
|
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2862 |
numSplitbars > 1 ifFalse:[^ nil]. |
4198 | 2863 |
colNr := self xAbsoluteToColumnIndex: x. |
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2864 |
colNr == 0 ifTrue:[^nil]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2865 |
rowNr := view yAbsoluteToLineNr: y. |
4198 | 2866 |
|
2867 |
||
2868 |
xTrs := view viewOrigin x. |
|
2869 |
xNxt := xSplitbars first - xTrs. |
|
2870 |
colInset := self splitbarInset. |
|
2871 |
||
4199
9e655a8d339f
Workaround stc bug, sigh
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4198
diff
changeset
|
2872 |
colNr ~~ 1 ifTrue:[x0 := (xSplitbars at:colNr - 1)] ifFalse:[x0 := 0]. |
4198 | 2873 |
x1 := (xSplitbars at:colNr) " - xTrs". |
2874 |
||
2875 |
"/ workaround due to drawing the selection frame |
|
2876 |
colNr == numSplitbars ifTrue:[ x1 := x1 + self textStartLeft ]. |
|
2877 |
||
2878 |
||
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2879 |
y0 := view yAbsoluteOfLine:(rowNr). |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2880 |
y1 := view yAbsoluteOfLine:(rowNr + 1). |
4198 | 2881 |
|
2882 |
^ Rectangle |
|
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2883 |
left: x0 + colInset - (view viewOrigin x) |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2884 |
top: y0 - (view viewOrigin y) |
4198 | 2885 |
width: x1 - x0 - colInset - colInset |
2886 |
height: y1 - y0 - 1 "/Separator line" |
|
2887 |
||
2888 |
"Created: / 17-04-2013 / 16:28:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2889 |
"Modified: / 18-04-2013 / 10:12:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2890 |
! |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2891 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2892 |
boundingBoxForCellAtXVisible:x yVisible:y |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2893 |
^self boundingBoxForCellAtXAbsolute: x + view viewOrigin x yAbsolute: y + view viewOrigin y |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2894 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2895 |
"Created: / 18-04-2013 / 10:15:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4198 | 2896 |
! |
2897 |
||
3717 | 2898 |
heightFor:anItem |
2899 |
"returns the height of an item on the view |
|
2900 |
" |
|
2901 |
|h| |
|
2902 |
||
2903 |
h := (anItem heightOn:view) max:minimumRequiredColumnHeight. |
|
2904 |
||
2905 |
"/ add some space for the horizontal separator |
|
2906 |
h := h + self splitbarInset. |
|
2907 |
||
2908 |
h odd ifTrue:[ ^ h + 1 ]. |
|
2909 |
^ h |
|
2910 |
! |
|
2911 |
||
2912 |
maxItemWidthOrNil |
|
2913 |
"returns the maximum item width for drawing; the |
|
2914 |
offset to the first splitbar minus an inset. |
|
2915 |
" |
|
2916 |
^ xSplitbars first - self splitbarInset. |
|
2917 |
! |
|
2918 |
||
2919 |
widthFor:anItem |
|
2920 |
"returns the width of an item on the view including the columns |
|
2921 |
but extracting the hierarchical tree inset. |
|
2922 |
" |
|
2923 |
|xStart xStop xDiff inset| |
|
2924 |
||
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2925 |
self showItemInAdditionToColumns ifFalse:[ ^ 0 ]. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2926 |
|
3717 | 2927 |
xStart := view xAbsoluteOfItem:anItem. |
2928 |
||
2929 |
hasFixedItemWidth ifFalse:[ |
|
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2930 |
inset := self splitbarInset. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2931 |
xStop := (anItem widthOn:view) + xStart + inset + inset. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2932 |
xDiff := xStop - xSplitbars first. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2933 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2934 |
xDiff > 0 ifTrue:[ |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2935 |
xDiff := xDiff + 10. "/ add more to have less computation |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2936 |
xSplitbars := xSplitbars collect:[:xSep| xSep + xDiff ]. |
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2937 |
]. |
3717 | 2938 |
]. |
2939 |
^ xSplitbars last - xStart |
|
4207
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2940 |
|
a7f50b5be37c
Added support for drawing only columns, not the item itself (implicit first-column)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4205
diff
changeset
|
2941 |
"Modified: / 24-04-2013 / 13:56:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2942 |
! |
2943 |
||
3723 | 2944 |
widthOfColumn:aColumn |
2945 |
"answer the width of a column or nil" |
|
2946 |
||
2947 |
|index x0 x1| |
|
2948 |
||
2949 |
index := columnDescriptors identityIndexOf:aColumn. |
|
2950 |
||
2951 |
index > 0 ifTrue:[ |
|
3728 | 2952 |
( (x0 := xSplitbars at:index ifAbsent:nil) notNil |
2953 |
and:[(x1 := xSplitbars at:(index + 1) ifAbsent:nil) notNil]) |
|
2954 |
ifTrue:[ |
|
2955 |
^ (x1 - x0 - (2 * (self splitbarInset))) max:0 |
|
2956 |
]. |
|
3723 | 2957 |
]. |
2958 |
^ nil |
|
2959 |
! |
|
2960 |
||
2961 |
widthOfItemColumn |
|
2962 |
"answer the current width of the column which holds the hierarchical |
|
2963 |
item label." |
|
2964 |
||
2965 |
^ xSplitbars at:1. |
|
2966 |
! |
|
2967 |
||
3717 | 2968 |
widthOfWidestLineBetween:firstLine and:lastLine |
2969 |
"returns the width of the longest line in pixels in a range |
|
4858 | 2970 |
- used to optimize scrolling, by limiting the scrolled area; |
2971 |
not for scrollbar or other width related stuff which should be exact." |
|
2972 |
||
3717 | 2973 |
|item| |
2974 |
||
2975 |
hasFixedItemWidth ifFalse:[ |
|
4858 | 2976 |
firstLine to:lastLine do:[:i| |
2977 |
item := view at:i ifAbsent:nil. |
|
2978 |
item notNil ifTrue:[self widthFor:item]. |
|
2979 |
]. |
|
3717 | 2980 |
]. |
2981 |
^ xSplitbars last |
|
2982 |
! |
|
2983 |
||
2984 |
xAbsoluteOfSplitbarAt:anIndex |
|
2985 |
"returns the physical x of the splitbar at an index |
|
2986 |
" |
|
2987 |
^ xSplitbars at:anIndex |
|
2988 |
! |
|
2989 |
||
3909 | 2990 |
xAbsoluteToColumnIndex:absX |
2991 |
"returns the column index for position x or 0 if not detected" |
|
2992 |
||
2993 |
|nextX| |
|
2994 |
||
2995 |
nextX := nil. |
|
2996 |
||
2997 |
"/ must walk reverse because a column could have a zero width |
|
2998 |
xSplitbars keysAndValuesReverseDo:[:index :x| |
|
2999 |
nextX notNil ifTrue:[ |
|
3000 |
x <= absX ifTrue:[ |
|
3001 |
nextX >= absX ifTrue:[^ index + 1]. |
|
3002 |
]. |
|
3003 |
]. |
|
3004 |
nextX := x. |
|
3005 |
]. |
|
3006 |
nextX notNil ifTrue:[ |
|
3007 |
nextX >= absX ifTrue:[^ 1]. |
|
3008 |
]. |
|
3009 |
^ 0 |
|
3010 |
||
3011 |
"Created: / 16-06-2010 / 16:25:33 / cg" |
|
3012 |
! |
|
3013 |
||
3717 | 3014 |
xAbsoluteToSplitbar:absX |
3909 | 3015 |
"returns the splitbar index at the position x or 0 if not detected" |
3016 |
||
3717 | 3017 |
|minX maxX| |
3018 |
||
3019 |
minX := absX - 2. |
|
3020 |
maxX := absX + 2. |
|
3021 |
||
3022 |
"/ must walk reverse because a column could have a zero width |
|
3023 |
xSplitbars keysAndValuesReverseDo:[:index :x| |
|
3909 | 3024 |
(x between:minX and:maxX) ifTrue:[^ index]. |
3717 | 3025 |
]. |
3026 |
^ 0 |
|
3909 | 3027 |
|
3028 |
"Modified: / 16-06-2010 / 16:23:12 / cg" |
|
3717 | 3029 |
! |
3030 |
||
3031 |
xVisibleOfLastSplitbar |
|
3032 |
"answer the visible x position of the last splitBar" |
|
3033 |
||
3034 |
^ self xVisibleOfSplitbarAt:(xSplitbars size). |
|
3035 |
! |
|
3036 |
||
3037 |
xVisibleOfSplitbarAt:anIndex |
|
3038 |
"returns the visible x of the splitbar at an index |
|
3039 |
" |
|
3040 |
|x| |
|
3041 |
||
3042 |
x := xSplitbars at:anIndex. |
|
3043 |
^ x - (view viewOrigin x) |
|
3044 |
! |
|
3045 |
||
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3046 |
xVisibleToColumnIndex:relX |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3047 |
"returns the column index for visible position x or 0 if not detected" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3048 |
^ self xAbsoluteToColumnIndex: relX + view viewOrigin x |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3049 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3050 |
"Created: / 18-04-2013 / 10:15:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3051 |
! |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3052 |
|
3717 | 3053 |
xVisibleToSplitbar:visX |
3909 | 3054 |
"returns the splitbar index at the position x or 0 if not detected" |
3055 |
||
3717 | 3056 |
^ self xAbsoluteToSplitbar:(visX + view viewOrigin x). |
3909 | 3057 |
|
3058 |
"Modified: / 16-06-2010 / 16:22:56 / cg" |
|
3717 | 3059 |
! ! |
3060 |
||
3061 |
!ListModelView::TableRenderer::ColumnDescriptor class methodsFor:'instance creation'! |
|
3062 |
||
3063 |
dataSetColumnSpec:aDataSetColumnSpec |
|
3064 |
^ self new dataSetColumnSpec:aDataSetColumnSpec |
|
3065 |
! |
|
3066 |
||
3067 |
new |
|
3068 |
ClipColumnQuerySignal isNil ifTrue:[ |
|
3728 | 3069 |
ClipColumnQuerySignal := QuerySignal new. |
3717 | 3070 |
]. |
3071 |
^ self basicNew initialize |
|
3072 |
! ! |
|
3073 |
||
3074 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'accessing'! |
|
3075 |
||
3076 |
alignment |
|
3077 |
"returns the aligmnent of the contents of the underlaying cell" |
|
3078 |
||
3079 |
|alignment| |
|
3080 |
||
3081 |
alignment := dataSetColumnSpec columnAlignment. |
|
3082 |
^ alignment ? #left |
|
3083 |
! |
|
3084 |
||
3723 | 3085 |
dataSetColumnSpec |
3086 |
^ dataSetColumnSpec |
|
3087 |
! |
|
3088 |
||
3089 |
dataSetColumnSpec:aDataSetColumnSpec |
|
3090 |
||
3091 |
aDataSetColumnSpec isSequenceable ifTrue:[ |
|
3728 | 3092 |
dataSetColumnSpec := DataSetColumnSpec decodeFromLiteralArray:aDataSetColumnSpec. |
3723 | 3093 |
] ifFalse:[ |
3728 | 3094 |
dataSetColumnSpec := aDataSetColumnSpec. |
3723 | 3095 |
]. |
3096 |
! |
|
3097 |
||
3717 | 3098 |
defaultColumnWidth |
3099 |
|width| |
|
3100 |
||
3101 |
width := (dataSetColumnSpec width ? 0) max:(dataSetColumnSpec minWidth ? 0). |
|
3102 |
width > 0 ifTrue:[^ width ]. |
|
3103 |
||
3104 |
^ 70 |
|
3105 |
! |
|
3106 |
||
3107 |
minimumRequiredColumnHeight |
|
4337
b5f21412bcb0
Hack to workaround new symbolic height specifier (which is made default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4323
diff
changeset
|
3108 |
|
b5f21412bcb0
Hack to workaround new symbolic height specifier (which is made default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4323
diff
changeset
|
3109 |
"Kludge because of CG's change...sigh." |
b5f21412bcb0
Hack to workaround new symbolic height specifier (which is made default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4323
diff
changeset
|
3110 |
dataSetColumnSpec height isNumber ifFalse:[ ^ 0 ]. |
3717 | 3111 |
^ dataSetColumnSpec height ? 0 |
4337
b5f21412bcb0
Hack to workaround new symbolic height specifier (which is made default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4323
diff
changeset
|
3112 |
|
b5f21412bcb0
Hack to workaround new symbolic height specifier (which is made default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4323
diff
changeset
|
3113 |
"Modified: / 23-08-2013 / 17:59:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 3114 |
! |
3115 |
||
3116 |
showVerticalSplitbar |
|
3117 |
"answer true if the verical splitbar is shown" |
|
3118 |
||
3119 |
^ dataSetColumnSpec showColSeparator ? true. |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3120 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3121 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3122 |
width |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3123 |
"Return |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3124 |
- width in px if the column (if explicit) |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3125 |
- nil if the width should be computed dynamically |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3126 |
based on view's width |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3127 |
" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3128 |
^width |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3129 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3130 |
"Modified (comment): / 07-05-2013 / 17:56:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3131 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3132 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3133 |
width:anInteger |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3134 |
width := anInteger. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3135 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3136 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3137 |
widthMin |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3138 |
"Return the minimal required width in px." |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3139 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3140 |
^dataSetColumnSpec minWidth |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3141 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3142 |
"Created: / 07-05-2013 / 17:57:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3143 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3144 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3145 |
widthSpec |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3146 |
"Return either |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3147 |
- width in px as Integer or |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3148 |
- relative width as Float" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3149 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3150 |
| w | |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3151 |
w := dataSetColumnSpec width. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3152 |
w isFloat ifTrue:[ ^ w ]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3153 |
w := w max: dataSetColumnSpec minWidth. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3154 |
w > 0 ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3155 |
w := 70 |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3156 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3157 |
^w |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3158 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3159 |
"Created: / 07-05-2013 / 17:58:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 3160 |
! ! |
3161 |
||
3162 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'displaying'! |
|
3163 |
||
3164 |
drawRowAt:aRowNr shownSelected:isShownSelected receiver:aReceiver x:x y:y w:w h:h on:aGC |
|
3165 |
"display a column for a specific row" |
|
3166 |
||
4901 | 3167 |
|oldClippingRectangle paint savedPaint label drawSelector | |
3717 | 3168 |
|
3169 |
isShownSelected ifFalse:[ |
|
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3170 |
"/ draw the background color if required by spec.. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3171 |
paint := self extractBackgroundColorFrom:aReceiver rowNr:aRowNr on:aGC. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3172 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3173 |
paint notNil ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3174 |
savedPaint := aGC paint. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3175 |
aGC paint:paint. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3176 |
"/ splitbarInset - draw from 0 to width of aGC (is clipped) |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3177 |
aGC fillRectangleX:0 y:y width:(aGC width) height:h. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3178 |
]. |
3717 | 3179 |
]. |
3180 |
w < 5 ifTrue:[ ^ self ]. "/ makes no sense to draw the label |
|
3181 |
||
3182 |
label := self extractColumnFrom:aReceiver rowNr:aRowNr on:aGC. |
|
3183 |
label isEmptyOrNil ifTrue:[^ self]. |
|
3184 |
||
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3185 |
(drawSelector := dataSetColumnSpec drawSelector) notNil ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3186 |
"/ Set clip rect to make sure nobody can draw outside the cell |
4901 | 3187 |
oldClippingRectangle := aGC clippingRectangleOrNil. |
5406 | 3188 |
aGC clippingBounds:(Rectangle left:x top:y width:w height:h). |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3189 |
drawSelector numArgs == 5 ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3190 |
aReceiver perform: drawSelector with: aGC with: x with: y with: w with: h. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3191 |
] ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3192 |
drawSelector numArgs == 6 ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3193 |
aReceiver perform: drawSelector with: aGC with: x with: y with: w with: h with: columnNumber |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3194 |
] ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3195 |
self error: 'Invalid draw selector' |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3196 |
] |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3197 |
]. |
5406 | 3198 |
aGC clippingBounds:oldClippingRectangle. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3199 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3200 |
|
4199
9e655a8d339f
Workaround stc bug, sigh
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4198
diff
changeset
|
3201 |
drawSelector notNil ifTrue:[ ^ self ]. |
9e655a8d339f
Workaround stc bug, sigh
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4198
diff
changeset
|
3202 |
|
3717 | 3203 |
ClipColumnQuerySignal handle:[:ex| |
4901 | 3204 |
oldClippingRectangle isNil ifTrue:[ |
5406 | 3205 |
oldClippingRectangle := aGC clippingBoundsOrNil. |
3206 |
aGC clippingBounds:(Rectangle left:x top:y width:w height:h). |
|
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3207 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3208 |
ex proceedWith:true. |
3717 | 3209 |
] do:[ |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3210 |
isShownSelected ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3211 |
paint := self extractForegroundColorFrom:aReceiver rowNr:aRowNr on:aGC. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3212 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3213 |
paint notNil ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3214 |
aGC paint:paint. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3215 |
] ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3216 |
savedPaint notNil ifTrue:[ aGC paint:savedPaint ]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3217 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3218 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3219 |
self drawObject:label x:x y:y w:w h:h on:aGC. |
3717 | 3220 |
]. |
4901 | 3221 |
oldClippingRectangle notNil ifTrue:[ |
5406 | 3222 |
aGC clippingBounds:oldClippingRectangle. |
3717 | 3223 |
]. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3224 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3225 |
"Modified: / 17-04-2013 / 13:05:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 3226 |
! ! |
3227 |
||
3228 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'extract values'! |
|
3229 |
||
3230 |
extractBackgroundColorFrom:aReceiver rowNr:aRowNr on:aView |
|
3231 |
|color selector| |
|
3232 |
||
3233 |
aReceiver notNil ifTrue:[ |
|
3728 | 3234 |
selector := dataSetColumnSpec backgroundSelector. |
3235 |
||
3236 |
selector notNil ifTrue:[ |
|
3237 |
color := aReceiver perform:selector withOptionalArgument:columnNumber and:aRowNr and:aView. |
|
3238 |
color notNil ifTrue:[ ^ color ]. |
|
3239 |
]. |
|
3717 | 3240 |
]. |
3241 |
^ dataSetColumnSpec backgroundColor. |
|
3242 |
! |
|
3243 |
||
3244 |
extractColumnFrom:aReceiver rowNr:aRowNr on:aView |
|
3245 |
|selector| |
|
3246 |
||
3247 |
aReceiver notNil ifTrue:[ |
|
4205 | 3248 |
selector := dataSetColumnSpec printSelector ? dataSetColumnSpec readSelector. |
3249 |
||
3250 |
selector notNil ifTrue:[ |
|
3251 |
^ aReceiver perform:selector withOptionalArgument:columnNumber and:aRowNr and:aView |
|
3252 |
]. |
|
3717 | 3253 |
]. |
3254 |
^ nil |
|
4205 | 3255 |
|
3256 |
"Modified: / 22-04-2013 / 14:04:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3717 | 3257 |
! |
3258 |
||
3259 |
extractForegroundColorFrom:aReceiver rowNr:aRowNr on:aView |
|
3260 |
|color selector| |
|
3261 |
||
3262 |
aReceiver notNil ifTrue:[ |
|
3728 | 3263 |
selector := dataSetColumnSpec foregroundSelector. |
3264 |
||
3265 |
selector notNil ifTrue:[ |
|
3266 |
color := aReceiver perform:selector withOptionalArgument:columnNumber and:aRowNr and:aView. |
|
3267 |
color notNil ifTrue:[ ^ color ]. |
|
3268 |
]. |
|
3717 | 3269 |
]. |
3270 |
^ dataSetColumnSpec foregroundColor. |
|
3271 |
! ! |
|
3272 |
||
3273 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'instance creation'! |
|
3274 |
||
3275 |
columnNumber:aNumber |
|
3276 |
columnNumber := aNumber. |
|
3277 |
! ! |
|
3278 |
||
3279 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'private displaying'! |
|
3280 |
||
3281 |
alignAndDisplay:anObject x:x y:y w:w on:aGC |
|
3282 |
"display an object on aGC; care for alignment" |
|
3283 |
||
3284 |
|x0 width align| |
|
3285 |
||
3286 |
x0 := x. |
|
3287 |
align := self alignment. |
|
3288 |
||
3289 |
align ~~ #left ifTrue:[ |
|
3728 | 3290 |
width := anObject widthOn:aGC. |
3291 |
||
3292 |
width < w ifTrue:[ |
|
3293 |
align == #right ifTrue:[ |
|
3294 |
x0 := x0 + w - width |
|
3295 |
] ifFalse:[ |
|
3296 |
x0 := x0 + ((w - width) // 2) |
|
3297 |
]. |
|
3298 |
]. |
|
3717 | 3299 |
]. |
3300 |
anObject displayOn:aGC x:x0 y:y. |
|
3301 |
! |
|
3302 |
||
3303 |
displayImage:anImage x:x y:y w:w h:h on:aGC |
|
3304 |
"display an image on aGC; answer the height used...." |
|
3305 |
||
3306 |
|height| |
|
3307 |
||
3308 |
height := anImage heightOn:aGC. |
|
3309 |
||
3310 |
height > h ifTrue:[ |
|
3728 | 3311 |
(self queryForClipColumnWithAvailableHeight:h) ifFalse:[ |
3312 |
^ height |
|
3313 |
]. |
|
3717 | 3314 |
]. |
3315 |
self alignAndDisplay:anImage x:x y:y w:w on:aGC. |
|
3316 |
^ height |
|
3317 |
! |
|
3318 |
||
3319 |
displayLabelAndIcon:aLabelAndIcon x:x y:y w:w h:h on:aGC |
|
3320 |
"display an image on aGC; answer the height used...." |
|
3321 |
||
3322 |
|height| |
|
3323 |
||
3324 |
height := aLabelAndIcon heightOn:aGC. |
|
3325 |
||
3326 |
height > h ifTrue:[ |
|
3728 | 3327 |
(self queryForClipColumnWithAvailableHeight:h) ifFalse:[ |
3328 |
^ height |
|
3329 |
]. |
|
3717 | 3330 |
]. |
3331 |
||
3332 |
self alignAndDisplay:aLabelAndIcon x:x y:(y + aGC font ascent) w:w on:aGC. |
|
3333 |
^ height |
|
3334 |
! |
|
3335 |
||
3336 |
displayString:aString x:x y:y w:w h:h on:aGC |
|
3337 |
"display a string on aGC; answer the height used...." |
|
3338 |
||
3339 |
|shortWidth font shortedLabel fontHeight| |
|
3340 |
||
3341 |
font := aGC font. |
|
3719 | 3342 |
fontHeight := font height. |
3717 | 3343 |
|
3344 |
aString isEmptyOrNil ifTrue:[ ^ fontHeight ]. |
|
3345 |
||
3346 |
(self queryForClipColumnWithAvailableHeight:h) ifFalse:[ |
|
3728 | 3347 |
^ fontHeight |
3717 | 3348 |
]. |
3719 | 3349 |
dataSetColumnSpec longStringCompression ifTrue:[ |
3728 | 3350 |
shortWidth := font widthOf:aString. |
3351 |
||
3352 |
shortWidth <= w ifTrue:[ |
|
3353 |
shortedLabel := aString. |
|
3354 |
] ifFalse:[ |
|
3355 |
|dottedString dottedWidth index| |
|
3356 |
||
3357 |
dottedString := '...'. |
|
3358 |
dottedWidth := font widthOf:dottedString. |
|
3359 |
||
3360 |
w < dottedWidth ifTrue:[ ^ fontHeight ]. "/ give up |
|
3361 |
||
3362 |
index := aString size // 2. |
|
3363 |
||
3364 |
[ index := index - 1. |
|
3365 |
||
3366 |
index > 0 ifTrue:[ |
|
3367 |
shortedLabel := (aString copyFirst:index), '...', (aString copyLast:index). |
|
3368 |
shortWidth := font widthOf:shortedLabel. |
|
3369 |
] ifFalse:[ |
|
3370 |
shortedLabel := dottedString. |
|
3371 |
shortWidth := dottedWidth. |
|
3372 |
]. |
|
3373 |
shortWidth > w |
|
3374 |
] whileTrue. |
|
3375 |
]. |
|
3717 | 3376 |
] ifFalse:[ |
3728 | 3377 |
shortedLabel := aString |
3717 | 3378 |
]. |
3379 |
||
3380 |
shortedLabel notNil ifTrue:[ |
|
3728 | 3381 |
self alignAndDisplay:shortedLabel x:x y:(y + aGC font ascent) w:w on:aGC. |
3717 | 3382 |
]. |
3383 |
^ fontHeight. |
|
3384 |
! |
|
3385 |
||
3386 |
drawObject:anObject x:x y:y w:w h:h on:aGC |
|
3387 |
"display any object (sequence of objects) on aGC; answer the height used...." |
|
3388 |
||
3389 |
|totalHeight usedHeight| |
|
3390 |
||
3391 |
h < 4 ifTrue:[ ^ h ]. |
|
3392 |
||
3393 |
anObject isEmptyOrNil ifTrue:[ ^ 2 ]. "/ nothing to draw; add 2 pixels |
|
3394 |
||
3395 |
anObject isImage ifTrue:[ |
|
5440 | 3396 |
^ self displayImage:anObject x:x y:y w:w h:h on:aGC. |
3717 | 3397 |
]. |
3398 |
anObject isString ifTrue:[ |
|
5440 | 3399 |
^ self displayString:anObject x:x y:y w:w h:h on:aGC. |
3728 | 3400 |
]. |
3717 | 3401 |
anObject isSequenceable ifFalse:[ |
5440 | 3402 |
"/ not yet handled.... |
3403 |
anObject isLabelAndIcon ifTrue:[ |
|
3404 |
^ self displayLabelAndIcon:anObject x:x y:y w:w h:h on:aGC |
|
3405 |
]. |
|
3406 |
||
3407 |
^ self displayString:(anObject printString) x:x y:y w:w h:h on:aGC |
|
3717 | 3408 |
]. |
3409 |
||
3410 |
totalHeight := 0. |
|
3411 |
||
3412 |
anObject do:[:aSubObj| |
|
5440 | 3413 |
totalHeight < h ifTrue:[ |
3414 |
usedHeight := self |
|
3415 |
drawObject:aSubObj |
|
3416 |
x:x |
|
3417 |
y:(y + totalHeight) |
|
3418 |
w:w |
|
3419 |
h:(h - totalHeight) |
|
3420 |
on:aGC. |
|
3421 |
||
3422 |
totalHeight := totalHeight + usedHeight. |
|
3423 |
]. |
|
3717 | 3424 |
]. |
3425 |
^ (h - totalHeight) |
|
5440 | 3426 |
|
3427 |
"Modified: / 04-02-2017 / 22:11:21 / cg" |
|
3717 | 3428 |
! |
3429 |
||
3430 |
queryForClipColumnWithAvailableHeight:anAvailableHeight |
|
3431 |
||
3432 |
anAvailableHeight > 8 ifTrue:[ |
|
3728 | 3433 |
^ (ClipColumnQuerySignal query) == true |
3717 | 3434 |
]. |
3435 |
^ false. |
|
3436 |
! ! |
|
3437 |
||
1390 | 3438 |
!ListModelView class methodsFor:'documentation'! |
3439 |
||
3440 |
version |
|
4858 | 3441 |
^ '$Header$' |
3891 | 3442 |
! |
3443 |
||
3444 |
version_CVS |
|
4858 | 3445 |
^ '$Header$' |
1390 | 3446 |
! ! |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
3447 |
|
4168 | 3448 |
|
1390 | 3449 |
ListModelView initialize! |