author | Stefan Vogel <sv@exept.de> |
Mon, 01 Aug 2016 11:13:28 +0200 | |
changeset 5196 | 48128e223c59 |
parent 5192 | a478b0f7c82f |
child 5206 | 4308605ea7d6 |
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. |
|
412 |
newFont := gc createFontOnDevice. |
|
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 |
|
450 |
"get the lineSpacing - thats an additional number of pixels, |
|
451 |
by which lines are vertically separated. |
|
452 |
" |
|
453 |
^ lineSpacing |
|
454 |
! |
|
455 |
||
456 |
lineSpacing:aNumber |
|
457 |
"set the lineSpacing - thats an additional number of pixels, |
|
458 |
by which lines are vertically separated. |
|
459 |
" |
|
460 |
lineSpacing ~= aNumber ifTrue:[ |
|
3728 | 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 |
" |
2644 | 914 |
|start stop yAbs yStart| |
1390 | 915 |
|
916 |
shown ifFalse:[^ self]. |
|
917 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
918 |
(self startOfLinesY size) == (self size + 1) ifFalse:[ |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
919 |
"oops, recompute the height of the contents (the first time after creation). |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
920 |
" |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
921 |
self recomputeHeightOfContents. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
922 |
|
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
923 |
self startOfLinesY size > 1 ifTrue:[ |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
924 |
"oops, the contents height changed |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
925 |
" |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
926 |
self invalidate. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
927 |
self contentsChanged. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
928 |
^ self |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
929 |
]. |
2598
b0c2d20f4062
recomputation of the contents height during redraw if not yet happen;
ca
parents:
2595
diff
changeset
|
930 |
]. |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
931 |
"/ widthOfContents isNil ifTrue:[ |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
932 |
"/ self preferredExtent |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
933 |
"/ ]. |
2644 | 934 |
yStart := y. |
935 |
start := self yVisibleToLineNr:y. |
|
1390 | 936 |
|
2644 | 937 |
start notNil ifTrue:[ |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
938 |
yAbs := y + h. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
939 |
stop := self yVisibleToLineNr:yAbs. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
940 |
|
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
941 |
stop isNil ifTrue:[ |
4573 | 942 |
stop := list size. |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
943 |
] ifFalse:[ |y0| |
4573 | 944 |
stop := stop min:list size. |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
945 |
y0 := self startOfLinesY at:stop ifAbsent:nil. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
946 |
y0 isNil ifTrue:[^ self]. "/ oops, lines differ (will be changed) |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
947 |
|
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
948 |
yAbs == y0 ifTrue:[ |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
949 |
stop := (stop - 1) max:start |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
950 |
]. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
951 |
]. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
952 |
|
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
953 |
start > stop ifTrue:[ |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
954 |
start := stop := nil. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
955 |
] ifFalse:[ |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
956 |
(listRenderer validateDrawableItemsFrom:start to:stop) ifFalse:[ |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
957 |
self invalidate. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
958 |
^ self. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
959 |
]. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
960 |
yStart := self yVisibleOfLine:start. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
961 |
]. |
2304 | 962 |
]. |
2644 | 963 |
self paint:bgColor. |
964 |
self fillRectangleX:x y:y width:w height:h. |
|
1390 | 965 |
|
2605
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
966 |
StopRedrawSignal handle:[:ex| |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
967 |
"/ an item changed its dimension during drawing, draw is aborted |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
968 |
self invalidate |
2605
3690a334fac1
bug fix: when setting #viewBackground: and computation of automatic scroll to x
ca
parents:
2600
diff
changeset
|
969 |
] do:[ |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
970 |
start notNil 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
|
971 |
listRenderer showItemInAdditionToColumns 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
|
972 |
self drawFrom:start to:stop x:x y:yStart 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
|
973 |
] ifFalse:[ |
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
|
974 |
self drawSelectionFrameFrom:start to:stop x:x y:yStart 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
|
975 |
]. |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
976 |
]. |
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
977 |
listRenderer postRedrawX:x y:yStart w:w from:start to:stop. |
2304 | 978 |
]. |
3974
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
979 |
|
e6b644647b6c
comment/format in: #redrawX:y:width:height:
Claus Gittinger <cg@exept.de>
parents:
3926
diff
changeset
|
980 |
"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
|
981 |
"Modified: / 24-04-2013 / 14:07:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1390 | 982 |
! ! |
983 |
||
3715 | 984 |
!ListModelView methodsFor:'enumerating'! |
985 |
||
986 |
visibleLinesAndItemsDo:aTwoArgBlock |
|
987 |
"enumerate over each visible item" |
|
988 |
||
989 |
|lineNr item| |
|
990 |
||
991 |
shown ifFalse:[^ self]. |
|
992 |
||
993 |
lineNr := self yVisibleToLineNr:1. |
|
994 |
lineNr isNil ifTrue:[ ^ self ]. |
|
995 |
||
996 |
[ item := list at:lineNr ifAbsent:[ ^ self ]. |
|
3728 | 997 |
aTwoArgBlock value:lineNr value:item. |
998 |
lineNr := lineNr + 1. |
|
999 |
(self yVisibleOfLine:lineNr) < height |
|
3715 | 1000 |
] whileTrue. |
1001 |
! ! |
|
1002 |
||
1390 | 1003 |
!ListModelView methodsFor:'event handling'! |
1004 |
||
1005 |
keyPress:aKey x:x y:y |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1006 |
"a key was pressed - handle page-keys here" |
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1007 |
|
1390 | 1008 |
<resource: #keyboard( #PreviousPage #NextPage #HalfPageUp #HalfPageDown |
3728 | 1009 |
#BeginOfText #EndOfText #ScrollUp #ScrollDown |
1010 |
)> |
|
1390 | 1011 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1012 |
|n| |
1390 | 1013 |
|
2408 | 1014 |
self size ~~ 0 ifTrue:[ |
3728 | 1015 |
(aKey == #PreviousPage) ifTrue:[^ self pageUp]. |
1016 |
(aKey == #NextPage) ifTrue:[^ self pageDown]. |
|
1017 |
(aKey == #HalfPageUp) ifTrue:[^ self halfPageUp]. |
|
1018 |
(aKey == #HalfPageDown) ifTrue:[^ self halfPageDown]. |
|
1019 |
(aKey == #BeginOfText) ifTrue:[^ self scrollToTop]. |
|
1020 |
(aKey == #EndOfText) ifTrue:[^ self scrollToBottom]. |
|
1021 |
||
1022 |
(aKey == #ScrollUp or:[aKey == #ScrollDown]) ifTrue:[ |
|
1023 |
n := 1 + (self sensor compressKeyPressEventsWithKey:aKey). |
|
1024 |
n := n * self verticalScrollStep. |
|
1025 |
||
1026 |
aKey == #ScrollUp ifTrue:[self scrollUp:n] |
|
1027 |
ifFalse:[self scrollDown:n]. |
|
1028 |
^ self |
|
1029 |
]. |
|
1390 | 1030 |
]. |
1031 |
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
|
1032 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1033 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1034 |
sizeChanged:how |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1035 |
previousExtent := self extent. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1036 |
listRenderer sizeChanged:how. |
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1037 |
super sizeChanged:how. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1038 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1039 |
"Modified: / 17-04-2013 / 11:41:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1390 | 1040 |
! ! |
1041 |
||
1554 | 1042 |
!ListModelView methodsFor:'event simulation'! |
1043 |
||
1044 |
syncronizeEvents |
|
2708 | 1045 |
<resource:#obsolete> |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1046 |
self obsoleteMethodWarning:'no longer supported'. |
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1047 |
^ false |
1554 | 1048 |
! |
1049 |
||
1050 |
syncronizeEvents:aBoolean |
|
2708 | 1051 |
<resource:#obsolete> |
2302
5a2a1d5d09f8
remove asynchronous handling of changes; always disabled because doesn't work
ca
parents:
2301
diff
changeset
|
1052 |
self obsoleteMethodWarning:'no longer supported'. |
1554 | 1053 |
! ! |
1054 |
||
1390 | 1055 |
!ListModelView methodsFor:'fetch resources'! |
1056 |
||
1057 |
colorOnDevice:aColor |
|
1058 |
"fetch a device colors |
|
1059 |
" |
|
5000 | 1060 |
^ aColor notNil ifTrue:[aColor onDevice:device] ifFalse:[nil] |
1390 | 1061 |
! |
1062 |
||
2488
74c81c1e30d7
imageOnDevice -> imageOnMyDevice
Claus Gittinger <cg@exept.de>
parents:
2482
diff
changeset
|
1063 |
imageOnMyDevice:anImage |
4609
6b04d0372a95
Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents:
4578
diff
changeset
|
1064 |
"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
|
1065 |
|
6b04d0372a95
Sending of Image>>#clearMaskedPixels moved to Image >> #asFormOnDevice:
Stefan Vogel <sv@exept.de>
parents:
4578
diff
changeset
|
1066 |
anImage isNil ifTrue:[^ nil]. |
5000 | 1067 |
^ anImage onDevice:device. |
1390 | 1068 |
! ! |
1069 |
||
1417 | 1070 |
!ListModelView methodsFor:'focus handling'! |
1071 |
||
1072 |
wantsFocusWithButtonPress |
|
1073 |
"catch the keyboard focus on button click |
|
1074 |
" |
|
1075 |
^ true |
|
1076 |
||
1077 |
||
1078 |
! |
|
1079 |
||
1080 |
wantsFocusWithPointerEnter |
|
1081 |
"views which like to take the keyboard focus |
|
1082 |
when the pointer enters can do so by redefining this |
|
1083 |
to return true" |
|
1084 |
||
1085 |
^ true |
|
1086 |
||
1087 |
! ! |
|
1088 |
||
2501 | 1089 |
!ListModelView methodsFor:'initialization & release'! |
1390 | 1090 |
|
1091 |
create |
|
1092 |
"fetch device dependent resources |
|
1093 |
" |
|
1094 |
super create. |
|
1095 |
self fetchResources. |
|
1096 |
! |
|
1097 |
||
1098 |
initStyle |
|
1099 |
"setup viewStyle specifics |
|
1100 |
" |
|
1101 |
super initStyle. |
|
1102 |
||
1103 |
DefaultBackgroundColor notNil ifTrue:[ |
|
3926 | 1104 |
viewBackground := DefaultBackgroundColor |
1390 | 1105 |
]. |
4569 | 1106 |
lineSpacing := 2. |
1390 | 1107 |
textStartLeft := 2. |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1108 |
textStartTop := 2. |
1390 | 1109 |
fgColor := DefaultForegroundColor. |
1110 |
bgColor := viewBackground. |
|
1111 |
startOfLinesY := OrderedCollection new. |
|
1112 |
||
3926 | 1113 |
self font:SelectionInListView defaultFont. |
1114 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1115 |
startOfLinesY add:(textStartTop + margin). "/ top inset of first line |
1390 | 1116 |
|
1117 |
DefaultShadowColor notNil ifTrue:[ |
|
3926 | 1118 |
shadowColor := DefaultShadowColor |
1390 | 1119 |
]. |
1120 |
||
1121 |
DefaultLightColor notNil ifTrue:[ |
|
3926 | 1122 |
lightColor := DefaultLightColor |
1390 | 1123 |
]. |
3926 | 1124 |
|
1125 |
"Modified: / 14-08-2010 / 12:24:02 / cg" |
|
1390 | 1126 |
! |
1127 |
||
1128 |
initialize |
|
1129 |
"setup default attributes |
|
1130 |
" |
|
1131 |
super initialize. |
|
1132 |
||
2261 | 1133 |
viewOrigin := 0@0. |
1134 |
bitGravity := #NorthWest. |
|
1135 |
enabled := true. |
|
1136 |
autoScroll := true. |
|
1827 | 1137 |
scrollWhenUpdating := #beginOfText. |
2261 | 1138 |
hasConstantHeight := false. |
2352 | 1139 |
|
3728 | 1140 |
listRenderer isNil ifTrue:[ |
3891 | 1141 |
listRenderer := self class defaultRenderer forView:self. |
2352 | 1142 |
]. |
2600 | 1143 |
self list:(self newDefaultList). |
1390 | 1144 |
! |
1145 |
||
1562 | 1146 |
mapped |
1147 |
"recompute list |
|
1148 |
" |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1149 |
"/ shown ifFalse:[ |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1150 |
"/ self recomputeHeightOfContents. |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1151 |
"/ 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
|
1152 |
"/ ]. |
3728 | 1153 |
listRenderer mapped. |
1562 | 1154 |
super mapped |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1155 |
|
1562 | 1156 |
! |
1157 |
||
1390 | 1158 |
recreate |
1832 | 1159 |
"sent after a snapin or a migration, reinit for new device" |
1828 | 1160 |
|
1390 | 1161 |
super recreate. |
1162 |
self fetchResources. |
|
1796
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1163 |
! |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1164 |
|
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1165 |
reinitialize |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1166 |
"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
|
1167 |
" |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1168 |
super reinitialize. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1169 |
self recomputeHeightOfContents. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1170 |
self contentsChanged. |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1773
diff
changeset
|
1171 |
|
2156 | 1172 |
! |
1173 |
||
1174 |
release |
|
1175 |
"remove dependencies |
|
1176 |
" |
|
3728 | 1177 |
listRenderer release. |
2643 | 1178 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1179 |
self listHolder removeDependent:self. |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1180 |
self list removeDependent:self. |
2156 | 1181 |
|
1182 |
super release |
|
1390 | 1183 |
! ! |
1184 |
||
1185 |
!ListModelView methodsFor:'private'! |
|
1186 |
||
1457 | 1187 |
hasDamage |
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1188 |
"return true, if any damage events (i.e. expose or resize) are pending" |
1457 | 1189 |
|
2482
13acaaf02528
Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents:
2464
diff
changeset
|
1190 |
^ self sensor hasDamageFor:self |
1457 | 1191 |
! |
1192 |
||
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1193 |
startOfLinesY |
3728 | 1194 |
"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
|
1195 |
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
|
1196 |
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
|
1197 |
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
|
1198 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1199 |
^ startOfLinesY |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1200 |
! |
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1201 |
|
2640 | 1202 |
xAbsoluteOfItem:anItem |
1203 |
"returns the absolute x of the labeled text |
|
1204 |
" |
|
1205 |
^ (self xVisibleOfItem:anItem) + viewOrigin x. |
|
1206 |
! |
|
1207 |
||
1208 |
xVisibleOfItem:anItem |
|
1209 |
"returns the visible x of the labeled text |
|
1210 |
" |
|
1211 |
^ textStartLeft - viewOrigin x |
|
1212 |
! |
|
1213 |
||
1390 | 1214 |
yAbsoluteOfLine:aLineNr |
1215 |
"given a lineNr, return y-coordinate absolute |
|
1216 |
" |
|
4578 | 1217 |
|y y2 y1 cache| |
1218 |
||
1219 |
cache := self startOfLinesY. |
|
1220 |
||
1221 |
(y := cache at:aLineNr ifAbsent:nil) notNil ifTrue:[ |
|
1222 |
^ y |
|
1446
fb46beba2d0c
startOfLines can have nil at end; lookup the first not nil
Claus Gittinger <cg@exept.de>
parents:
1444
diff
changeset
|
1223 |
]. |
1744 | 1224 |
|
1225 |
"/ recompute a y position |
|
4578 | 1226 |
y1 := cache at:1 ifAbsent:textStartTop. |
1227 |
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
|
1228 |
^ aLineNr * (y2 - y1) + y1 |
1390 | 1229 |
! |
1230 |
||
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1231 |
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
|
1232 |
"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
|
1233 |
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
|
1234 |
" |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1235 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1236 |
|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
|
1237 |
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
|
1238 |
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
|
1239 |
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
|
1240 |
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
|
1241 |
| |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1242 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1243 |
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
|
1244 |
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
|
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 |
(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
|
1247 |
"/ 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
|
1248 |
(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
|
1249 |
^ nil |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1250 |
]. |
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 |
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
|
1253 |
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
|
1254 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1255 |
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
|
1256 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1257 |
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
|
1258 |
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
|
1259 |
^ 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
|
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 |
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
|
1263 |
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
|
1264 |
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
|
1265 |
^ 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
|
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 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1268 |
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
|
1269 |
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
|
1270 |
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
|
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 |
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
|
1273 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1274 |
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
|
1275 |
[(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
|
1276 |
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
|
1277 |
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
|
1278 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1279 |
^ 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 |
]. |
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 ~~ 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
|
1283 |
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
|
1284 |
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
|
1285 |
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
|
1286 |
]. |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1287 |
^ 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 |
"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
|
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 |
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
|
1293 |
"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
|
1294 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1295 |
^ 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
|
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 |
"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
|
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 |
|
1390 | 1300 |
yVisibleOfLine:aLineNr |
1301 |
"given a lineNr, return y-coordinate in view |
|
1302 |
" |
|
1744 | 1303 |
^ (self yAbsoluteOfLine:aLineNr) - viewOrigin y |
1390 | 1304 |
|
1305 |
||
1306 |
! |
|
1307 |
||
1308 |
yVisibleToLineNr:yVisible |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1309 |
"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
|
1310 |
or nil if beyond of list. |
1390 | 1311 |
" |
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1312 |
^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
|
1313 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
1314 |
"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
|
1315 |
! |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1316 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1317 |
yVisibleToRowNr:yVisible |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1318 |
"for protocol compatibility with DSVColumnView" |
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1319 |
|
2fcd6ccdaa7b
+yVisibleToRowNr: for protocol compatibility
Claus Gittinger <cg@exept.de>
parents:
2458
diff
changeset
|
1320 |
^ self yVisibleToLineNr:yVisible |
1390 | 1321 |
! ! |
1322 |
||
1323 |
!ListModelView methodsFor:'protocol'! |
|
1324 |
||
1325 |
fetchResources |
|
1326 |
"fetch device colors and ..., to avoid reallocation at redraw time; |
|
1327 |
*** called after a create or snapin to fetch all device resources |
|
1328 |
" |
|
1329 |
fgColor := self colorOnDevice:fgColor. |
|
1330 |
bgColor := self colorOnDevice:bgColor. |
|
4500 | 1331 |
gc createFontOnDevice. |
1390 | 1332 |
! |
1333 |
||
3533 | 1334 |
heightForLines:numberOfLines |
1335 |
|h| |
|
1336 |
||
1337 |
h := self lineHeightFor:'Yg'. |
|
1338 |
^ h * numberOfLines |
|
1339 |
! |
|
1340 |
||
2352 | 1341 |
lineHeightFor:anItem |
1342 |
"returns the computed line height for an item |
|
1390 | 1343 |
" |
3728 | 1344 |
^ lineSpacing + (listRenderer heightFor:anItem) |
1390 | 1345 |
! |
1346 |
||
1347 |
listSizeChanged:anIndex nLines:noLines |
|
1348 |
"list size changed; information is stored to recompute the |
|
1349 |
width if required( preferredExtent, horizontal scroller ... ). |
|
1350 |
see: widthOfContents |
|
1351 |
*** if nLines is negative, lines are removed otherwise added. |
|
1352 |
" |
|
1353 |
|start "{ Class:SmallInteger }" |
|
1354 |
stop "{ Class:SmallInteger }" |
|
1355 |
size "{ Class:SmallInteger }" |
|
1356 |
| |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1357 |
"/ preferredExtent := nil. |
1390 | 1358 |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1359 |
cachedPreferredExtent := nil. |
1390 | 1360 |
widthOfContents isNil ifTrue:[ "/ recompute whole list |
3728 | 1361 |
^ self |
1390 | 1362 |
]. |
1363 |
||
2408 | 1364 |
(noLines < 0 or:[(size := self size) <= noLines]) ifTrue:[ |
3728 | 1365 |
widthOfContents := nil. "/ force recompute whole list |
1366 |
^ self |
|
1390 | 1367 |
]. |
1368 |
||
1369 |
stop := anIndex + noLines - 1. "/ recompute a range |
|
1370 |
start := anIndex. |
|
1371 |
||
1372 |
computeWidthInRange notNil ifTrue:[ |
|
3728 | 1373 |
start := computeWidthInRange y. |
1374 |
stop < start ifTrue:[stop := start min:size]. |
|
1375 |
start := (computeWidthInRange x) min:anIndex. |
|
1390 | 1376 |
]. |
1377 |
computeWidthInRange := start@stop |
|
1378 |
! |
|
1379 |
||
1457 | 1380 |
lostSynchronisation |
1381 |
"called when the changes derived from the model are faster than the handling |
|
1382 |
" |
|
3892 | 1383 |
|
1384 |
self recomputeHeightOfContents. |
|
1385 |
self invalidate. |
|
1386 |
self contentsChanged |
|
1457 | 1387 |
! |
1388 |
||
2644 | 1389 |
newDefaultList |
1390 |
"creates and returns a new default list class, on default a List |
|
1391 |
" |
|
1392 |
^ List new |
|
1393 |
! |
|
1394 |
||
1390 | 1395 |
widthOfWidestLineBetween:firstLine and:lastLine |
1396 |
"return the width in pixels of the widest line in a range |
|
4858 | 1397 |
- used to optimize scrolling, by limiting the scrolled area; |
1398 |
not for scrollbar or other width related stuff which should be exact." |
|
1399 |
||
2645 | 1400 |
|item width| |
1401 |
||
3728 | 1402 |
width := listRenderer widthOfWidestLineBetween:firstLine and:lastLine. |
2644 | 1403 |
width notNil ifTrue:[^ width]. |
1404 |
||
1390 | 1405 |
width := textStartLeft. |
1406 |
||
1407 |
firstLine to:lastLine do:[:anIndex| |
|
4858 | 1408 |
item := self at:anIndex ifAbsent:nil. |
1409 |
||
1410 |
item isNil ifTrue:[^ width + textStartLeft]. |
|
1411 |
||
1412 |
width := (listRenderer widthFor:item) max:width |
|
1390 | 1413 |
]. |
1414 |
^ width + textStartLeft |
|
1415 |
! ! |
|
1416 |
||
1820 | 1417 |
!ListModelView methodsFor:'queries'! |
1418 |
||
2274
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1419 |
isLineVisible:aLineNr |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1420 |
"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
|
1421 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1422 |
^ self isLineVisible:aLineNr in:self extent |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1423 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1424 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1425 |
isLineVisible:aLineNr in:anExtentPoint |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1426 |
"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
|
1427 |
|
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1428 |
|y| |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1429 |
y := self yVisibleOfLine:aLineNr. |
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 |
^ (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
|
1432 |
! |
c973acbc021d
only make selection visible after a resize, if it was visible before
ca
parents:
2265
diff
changeset
|
1433 |
|
3201 | 1434 |
lineIsFullyVisible:aLineNr |
1435 |
"returns true if the line is fully visible" |
|
1436 |
||
1437 |
|y| |
|
1438 |
||
1439 |
shown ifFalse:[^ false]. |
|
1440 |
||
1441 |
y := self yVisibleOfLine:aLineNr. |
|
1442 |
||
1443 |
(y between:0 and:height) ifTrue:[ |
|
3728 | 1444 |
y := self yVisibleOfLine:(aLineNr + 1). |
1445 |
y <= height ifTrue:[^ true ]. |
|
3201 | 1446 |
]. |
1447 |
^ false |
|
1448 |
! |
|
1449 |
||
1820 | 1450 |
size |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1451 |
"returns the number of list entries |
1820 | 1452 |
" |
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1453 |
^ self list size |
1820 | 1454 |
! ! |
1455 |
||
1390 | 1456 |
!ListModelView methodsFor:'recomputation'! |
1457 |
||
1458 |
preferredExtent |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1459 |
"returns the preferred extent" |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1460 |
|
1390 | 1461 |
|x y| |
1462 |
||
3576
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1463 |
"/ If I have an explicit preferredExtent.. |
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1464 |
explicitExtent notNil ifTrue:[ |
3728 | 1465 |
^ explicitExtent |
3576
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1466 |
]. |
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1467 |
|
e990d7f45310
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3533
diff
changeset
|
1468 |
"/ 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
|
1469 |
preferredExtent notNil ifTrue:[ |
3728 | 1470 |
^ preferredExtent |
1390 | 1471 |
]. |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1472 |
cachedPreferredExtent isNil ifTrue:[ |
3728 | 1473 |
y := self heightOfContents. |
1474 |
x := self widthOfContents. |
|
1475 |
cachedPreferredExtent := x@y |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1476 |
]. |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1477 |
^ cachedPreferredExtent |
1390 | 1478 |
! |
1479 |
||
1480 |
recomputeHeightOfContents |
|
1481 |
"recompute all the y positions |
|
1482 |
" |
|
1643 | 1483 |
|newList |
3728 | 1484 |
yAbs "{ Class: SmallInteger }" |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1485 |
size "{ Class: SmallInteger }"| |
1390 | 1486 |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1487 |
yAbs := (textStartTop + margin). "/ top inset of first line |
2408 | 1488 |
size := self size. |
1643 | 1489 |
newList := OrderedCollection new:(size + 1). |
1490 |
newList add:yAbs. |
|
1390 | 1491 |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1492 |
size ~~ 0 ifTrue:[ |
4569 | 1493 |
1 to:size do:[:anIndex| |
4635 | 1494 |
yAbs := yAbs + (self heightOfLineAt:anIndex). |
4569 | 1495 |
newList add:yAbs |
1496 |
]. |
|
1390 | 1497 |
]. |
1643 | 1498 |
startOfLinesY := newList. |
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1499 |
cachedPreferredExtent := nil. |
1390 | 1500 |
! ! |
1501 |
||
1502 |
!ListModelView methodsFor:'scroller interface'! |
|
1503 |
||
2644 | 1504 |
getWidthOfContents |
1505 |
^ widthOfContents |
|
1506 |
! |
|
1507 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1508 |
heightOfAnyNonNilItem |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1509 |
"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
|
1510 |
|
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1511 |
|item| |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1512 |
|
4635 | 1513 |
item := list |
1514 |
detect:[:i | i notNil] |
|
1515 |
ifNone:[ ^ lineSpacing + gc font height ]. "arbitrary" |
|
1516 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1517 |
^ self lineHeightFor:item. |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1518 |
! |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1519 |
|
1390 | 1520 |
heightOfContents |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1521 |
"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
|
1522 |
|
2595
1ab5dc7d4796
create a default list; thus we have not to test for nil
ca
parents:
2569
diff
changeset
|
1523 |
^ self startOfLinesY last ? 0 |
1390 | 1524 |
! |
1525 |
||
2261 | 1526 |
heightOfLineAt:aLineNr |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1527 |
"returns the height of a line at an index (including lineSpacing...)" |
2261 | 1528 |
|
1529 |
hasConstantHeight ifTrue:[ |
|
3728 | 1530 |
constantHeight isNil ifTrue:[ |
1531 |
constantHeight := self heightOfAnyNonNilItem. |
|
1532 |
]. |
|
1533 |
^ constantHeight |
|
2261 | 1534 |
]. |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1535 |
^ self realHeightOfLineAt:aLineNr |
2261 | 1536 |
! |
1537 |
||
1390 | 1538 |
innerHeight |
1539 |
"returns the inner height of the contents shown |
|
1540 |
" |
|
1541 |
^ height - margin - margin |
|
1542 |
||
1543 |
! |
|
1544 |
||
1545 |
innerWidth |
|
1546 |
"returns the inner width of the contents shown |
|
1547 |
" |
|
1548 |
^ width - margin - margin |
|
1549 |
||
1550 |
! |
|
1551 |
||
1552 |
maxViewOriginY |
|
1553 |
"returns the maximum possible y of the view origin |
|
1554 |
" |
|
1555 |
^ (self heightOfContents - self innerHeight) max:0 |
|
1556 |
||
1557 |
||
1558 |
! |
|
1559 |
||
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1560 |
realHeightOfLineAt:aLineNr |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1561 |
"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
|
1562 |
|
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1563 |
|item| |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1564 |
|
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1565 |
item := self at:aLineNr ifAbsent:nil. |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1566 |
item notNil ifTrue:[ |
4500 | 1567 |
^ self lineHeightFor:item |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1568 |
]. |
4635 | 1569 |
^ lineSpacing + gc font height "arbitrary" |
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1570 |
! |
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1571 |
|
2644 | 1572 |
setWidthOfContents: aWidth |
1573 |
widthOfContents := aWidth. |
|
1574 |
! |
|
1575 |
||
1390 | 1576 |
verticalScrollStep |
3501 | 1577 |
"return the amount to scroll when stepping up/down (also used for mouseWheel)." |
1578 |
||
1390 | 1579 |
^ 10 |
1580 |
! |
|
1581 |
||
1582 |
viewOrigin |
|
3728 | 1583 |
"return the viewOrigin; thats the coordinate of the contents |
1390 | 1584 |
which is shown topLeft in the view. |
1585 |
" |
|
1586 |
^ viewOrigin |
|
1587 |
||
1588 |
! |
|
1589 |
||
1590 |
widthOfContents |
|
1591 |
"return the width of the contents in pixels |
|
1592 |
" |
|
1593 |
|range |
|
1594 |
size "{ Class:SmallInteger }" |
|
1595 |
start "{ Class:SmallInteger }" |
|
1596 |
stop "{ Class:SmallInteger }" |
|
1597 |
| |
|
1598 |
(widthOfContents notNil and:[computeWidthInRange isNil]) ifTrue:[ |
|
3891 | 1599 |
^ widthOfContents + textStartLeft |
1390 | 1600 |
]. |
1601 |
range := computeWidthInRange. |
|
1602 |
computeWidthInRange := nil. |
|
3483
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1603 |
"/ preferredExtent := nil. |
c9946ba07f41
preferredExtent fixed (do not use pref'Extent as a cache)
Claus Gittinger <cg@exept.de>
parents:
3390
diff
changeset
|
1604 |
"/ cachedPreferredExtent := nil. |
2384 | 1605 |
|
2408 | 1606 |
size := self size. |
1390 | 1607 |
|
1608 |
size == 0 ifTrue:[ |
|
3891 | 1609 |
widthOfContents := 20. |
1390 | 1610 |
] ifFalse:[ |
3891 | 1611 |
widthOfContents isNil ifTrue:[ |
1612 |
widthOfContents := self widthOfWidestLineBetween:1 and:size |
|
1613 |
] ifFalse:[ |
|
1614 |
start := range x. |
|
1615 |
stop := range y min:size. |
|
1616 |
||
1617 |
start > stop ifFalse:[ |
|
1618 |
size := self widthOfWidestLineBetween:start and:stop. |
|
1619 |
||
1620 |
widthOfContents < size ifTrue:[ |
|
1621 |
widthOfContents := size |
|
1622 |
] |
|
1623 |
] |
|
1624 |
] |
|
1390 | 1625 |
]. |
1626 |
^ widthOfContents + textStartLeft |
|
1627 |
! |
|
1628 |
||
1629 |
xOriginOfContents |
|
1630 |
"return the horizontal origin of the contents in pixels |
|
1631 |
" |
|
3728 | 1632 |
^ viewOrigin x |
1390 | 1633 |
|
1634 |
! |
|
1635 |
||
1636 |
yOriginOfContents |
|
1637 |
"return the vertical origin of the contents in pixels |
|
1638 |
" |
|
1639 |
^ viewOrigin y |
|
1640 |
||
1641 |
! ! |
|
1642 |
||
1643 |
!ListModelView methodsFor:'scrolling'! |
|
1644 |
||
4858 | 1645 |
basicScrollTo:anOrigin redraw:doRedraw |
1390 | 1646 |
"change origin to have newOrigin be visible at the top-left. |
1647 |
" |
|
1538 | 1648 |
|newOrg dltOrg winGrp |
1390 | 1649 |
innerWT "{ Class:SmallInteger }" |
1650 |
innerHG "{ Class:SmallInteger }" |
|
1651 |
h "{ Class:SmallInteger }" |
|
1652 |
x "{ Class:SmallInteger }" |
|
1653 |
x0 "{ Class:SmallInteger }" |
|
1654 |
x1 "{ Class:SmallInteger }" |
|
1655 |
y "{ Class:SmallInteger }" |
|
1656 |
w "{ Class:SmallInteger }" |
|
1657 |
y0 "{ Class:SmallInteger }" |
|
1658 |
y1 "{ Class:SmallInteger }" |
|
1659 |
dX "{ Class:SmallInteger }" |
|
1660 |
dY "{ Class:SmallInteger }" |
|
1661 |
| |
|
1531 | 1662 |
|
1390 | 1663 |
innerWT := self innerWidth. |
1664 |
innerHG := self innerHeight. |
|
1665 |
||
1666 |
h := viewOrigin y. |
|
1667 |
||
1668 |
(y := anOrigin y) > h ifTrue:[ "/ end of contents |
|
3891 | 1669 |
y > (dY := self maxViewOriginY) ifTrue:[ |
1670 |
y := dY max:h |
|
1671 |
] |
|
1390 | 1672 |
] ifFalse:[ |
3891 | 1673 |
y := y max:0. |
1390 | 1674 |
]. |
1675 |
||
1676 |
(x := anOrigin x) > 0 ifTrue:[ |
|
3891 | 1677 |
x := x min:(self widthOfContents - innerWT). |
1390 | 1678 |
]. |
1679 |
x := x max:0. |
|
1680 |
newOrg := (x @ y). |
|
1681 |
dltOrg := newOrg - viewOrigin. |
|
1682 |
dX := dltOrg x. |
|
1683 |
dY := dltOrg y. |
|
1684 |
||
1685 |
(dX == 0 and:[dY == 0]) ifTrue:[ |
|
3891 | 1686 |
^ self |
1390 | 1687 |
]. |
3891 | 1688 |
|
1534 | 1689 |
dY := dY abs. |
1690 |
dX := dX abs. |
|
1390 | 1691 |
|
4858 | 1692 |
( shown not "/ check if we are shown |
1693 |
or:[(dX ~~ 0 and:[dY ~~ 0]) "/ scroll vertical & horizontal |
|
1694 |
or:[(innerHG - dY < 20 or:[innerWT - dX < 20])]] "/ faster to invalidate screen |
|
1534 | 1695 |
) ifTrue:[ |
3891 | 1696 |
viewOrigin := newOrg. |
1697 |
self originChanged:dltOrg. |
|
4858 | 1698 |
shown ifTrue:[ self invalidate ]. |
3891 | 1699 |
^ self |
1534 | 1700 |
]. |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1701 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1702 |
(winGrp := self windowGroup) notNil ifTrue:[ |
3891 | 1703 |
winGrp processRealExposeEventsFor:self. |
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1704 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1705 |
|
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1706 |
self originWillChange. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1707 |
|
3892 | 1708 |
(doRedraw and:[shown]) ifFalse:[ |
3891 | 1709 |
viewOrigin := newOrg. |
1710 |
self originChanged:dltOrg. |
|
1711 |
^ self |
|
1753
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1712 |
]. |
17769f8df493
#scrollTo:redraw: first check whether full invalidate otherwise processRealExposeEventsFor:
ca
parents:
1752
diff
changeset
|
1713 |
|
1531 | 1714 |
self catchExpose. |
1715 |
viewOrigin := newOrg. |
|
1716 |
||
1390 | 1717 |
dY ~~ 0 ifTrue:[ "/ SCROLL VERTICAL |
3891 | 1718 |
y0 := y1 := margin + dY. |
1719 |
h := innerHG - dY. |
|
1720 |
||
1721 |
dltOrg y < 0 ifTrue:[y0 := margin. y := y0] |
|
1722 |
ifFalse:[y1 := margin. y := y1 + h]. |
|
1723 |
||
1724 |
self copyFrom:self x:margin y:y0 toX:margin y:y1 width:innerWT height:h async:true. |
|
1725 |
self invalidateX:margin y:y width:innerWT height:(innerHG - h). |
|
1390 | 1726 |
|
1727 |
] ifFalse:[ "/ SCROLL HORIZONTAL |
|
3891 | 1728 |
x0 := x1 := dX + margin. |
1729 |
w := innerWT - dX. |
|
1730 |
||
1731 |
dltOrg x < 0 ifTrue:[x0 := x := margin ] |
|
1732 |
ifFalse:[x1 := margin. x := w]. |
|
1733 |
||
1734 |
self copyFrom:self x:x0 y:margin toX:x1 y:margin width:w height:innerHG async:true. |
|
1735 |
self invalidateX:x y:margin width:(width - w) height:innerHG. |
|
1390 | 1736 |
]. |
1737 |
self originChanged:dltOrg. |
|
1531 | 1738 |
self waitForExpose. |
1739 |
||
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1740 |
winGrp notNil ifTrue:[ |
3891 | 1741 |
winGrp processRealExposeEventsFor:self. |
2458
0411397ef0a2
readraw after scroll: process expose events.
Claus Gittinger <cg@exept.de>
parents:
2408
diff
changeset
|
1742 |
]. |
1390 | 1743 |
! |
1744 |
||
4858 | 1745 |
halfPageDown |
1746 |
"scroll down half a page |
|
1747 |
" |
|
1748 |
self scrollDown:(height // 2). |
|
1749 |
||
1750 |
! |
|
1751 |
||
1752 |
halfPageUp |
|
1753 |
"scroll up half a page |
|
1754 |
" |
|
1755 |
self scrollUp:(height // 2). |
|
1756 |
||
1757 |
! |
|
1758 |
||
1759 |
makeLineVisible:aLnNr |
|
1760 |
"make the line visible |
|
1761 |
" |
|
1762 |
aLnNr notNil ifTrue:[ |
|
1763 |
self scrollToLine:aLnNr |
|
1764 |
]. |
|
1765 |
! |
|
1766 |
||
1767 |
scrollTo:anOrigin redraw:doRedraw |
|
1768 |
"change origin to have newOrigin be visible at the top-left. |
|
1769 |
" |
|
1770 |
|process| |
|
1771 |
||
1772 |
"/ check if we are still in scrolling due to async. processes |
|
1773 |
||
1774 |
((process := activeScrollProcess) notNil and:[process isDead]) ifTrue:[ |
|
1775 |
activeScrollProcess := nil. |
|
1776 |
]. |
|
1777 |
activeScrollProcess notNil ifTrue:[^ self]. |
|
1778 |
activeScrollProcess := Processor activeProcess. |
|
1779 |
self basicScrollTo:anOrigin redraw:doRedraw. |
|
1780 |
activeScrollProcess := nil. |
|
1781 |
! |
|
1782 |
||
1390 | 1783 |
scrollToLine:aLineNumber |
3891 | 1784 |
"make line visible" |
1785 |
||
1744 | 1786 |
|inHg "{ Class:SmallInteger }" |
1787 |
yTop "{ Class:SmallInteger }" |
|
1788 |
orgY "{ Class:SmallInteger }" |
|
3891 | 1789 |
yBot "{ Class:SmallInteger }"| |
1790 |
||
1791 |
(aLineNumber notNil and:[aLineNumber between:1 and:(self size)]) ifFalse:[ |
|
1792 |
^ self |
|
1390 | 1793 |
]. |
1794 |
||
1744 | 1795 |
yTop := self yAbsoluteOfLine:aLineNumber. |
1796 |
inHg := self innerHeight. |
|
1797 |
orgY := viewOrigin y. |
|
1798 |
||
1799 |
yTop > orgY ifTrue:[ |
|
3891 | 1800 |
yBot := self yAbsoluteOfLine:(aLineNumber + 1). |
1801 |
||
1802 |
yBot <= (orgY + inHg) ifTrue:[ |
|
1803 |
^ self |
|
1804 |
]. |
|
1390 | 1805 |
]. |
1744 | 1806 |
yTop := (yTop - (inHg // 2)) max:0. |
1807 |
self scrollTo:(viewOrigin x @ yTop). |
|
1390 | 1808 |
! ! |
1809 |
||
1748 | 1810 |
!ListModelView methodsFor:'scrolling auto'! |
1811 |
||
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1812 |
startAutoScroll:aSelectorOrBlock distance:aDistance |
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1813 |
"setup for auto-scroll (when button-press-moving below/above view); |
1748 | 1814 |
- timeDelta for scroll is computed from distance |
1815 |
" |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1816 |
|timeDelta scrollBlock| |
1748 | 1817 |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1818 |
autoScroll ifFalse:[ |
3728 | 1819 |
self stopAutoScroll. |
1820 |
^ self |
|
1748 | 1821 |
]. |
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1822 |
|
1748 | 1823 |
autoScrollBlock notNil ifTrue:[ |
3728 | 1824 |
Processor removeTimedBlock:autoScrollBlock. |
1748 | 1825 |
] ifFalse:[ |
3728 | 1826 |
self compressMotionEvents:false. |
1748 | 1827 |
]. |
1828 |
||
1829 |
timeDelta := 0.5 / (aDistance abs). |
|
1830 |
||
3728 | 1831 |
scrollBlock := |
1832 |
[ |
|
1833 |
aSelectorOrBlock isSymbol ifTrue:[ |
|
1834 |
self perform:aSelectorOrBlock. |
|
1835 |
] ifFalse:[ |
|
1836 |
aSelectorOrBlock value |
|
1837 |
]. |
|
1838 |
autoScrollBlock notNil ifTrue:[ |
|
1839 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
|
1840 |
] |
|
1841 |
]. |
|
2670
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1842 |
|
27dacfff1d6d
autoScroll: let timedBlock push an event which performs the scroll
Claus Gittinger <cg@exept.de>
parents:
2659
diff
changeset
|
1843 |
autoScrollBlock := [self sensor pushUserEvent:#value for:scrollBlock]. |
1748 | 1844 |
Processor addTimedBlock:autoScrollBlock afterSeconds:timeDelta. |
1845 |
! |
|
1846 |
||
1847 |
stopAutoScroll |
|
1848 |
"stop any autoScroll |
|
1849 |
" |
|
1850 |
autoScrollBlock notNil ifTrue:[ |
|
2265 | 1851 |
Processor removeTimedBlock:autoScrollBlock. |
1852 |
autoScrollBlock := nil. |
|
1853 |
self compressMotionEvents:true. |
|
1748 | 1854 |
]. |
1855 |
! ! |
|
1856 |
||
2644 | 1857 |
!ListModelView methodsFor:'selection'! |
1858 |
||
1859 |
hasSelection |
|
1860 |
"on default false is returned |
|
1861 |
" |
|
1862 |
^ false |
|
1863 |
! ! |
|
1864 |
||
2352 | 1865 |
!ListModelView::Renderer class methodsFor:'documentation'! |
1866 |
||
1867 |
documentation |
|
1868 |
" |
|
1869 |
prepared for ListItemRenderer |
|
1870 |
.... SelectionItemRenderer ... |
|
1871 |
||
1872 |
goal: |
|
3728 | 1873 |
allow the user to redefine the display operation and the dimesion queries |
2352 | 1874 |
" |
1875 |
! ! |
|
1876 |
||
1877 |
!ListModelView::Renderer class methodsFor:'instance creation'! |
|
1878 |
||
1879 |
forView:aView |
|
1880 |
|renderer| |
|
1881 |
||
1882 |
renderer := self basicNew initialize. |
|
1883 |
renderer forView:aView. |
|
1884 |
^ renderer |
|
1885 |
! ! |
|
1886 |
||
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
|
1887 |
!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
|
1888 |
|
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
|
1889 |
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
|
1890 |
"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
|
1891 |
|
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
|
1892 |
^ 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
|
1893 |
|
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
|
1894 |
"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
|
1895 |
! ! |
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 |
|
2640 | 1897 |
!ListModelView::Renderer methodsFor:'change & update'! |
1898 |
||
1899 |
listWillChange |
|
2852
c5651fcf9770
change and update: MUST update everything if no
Claus Gittinger <cg@exept.de>
parents:
2745
diff
changeset
|
1900 |
"called before the list changed, clear caches etc. |
2640 | 1901 |
here nothing is done |
1902 |
" |
|
2644 | 1903 |
! |
1904 |
||
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1905 |
sizeChanged:how |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1906 |
"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
|
1907 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1908 |
"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
|
1909 |
! |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
1910 |
|
2644 | 1911 |
withinUpdateFromListDo:aBlock |
1912 |
"handle an update from the list |
|
1913 |
" |
|
1914 |
aBlock value |
|
2640 | 1915 |
! ! |
1916 |
||
2352 | 1917 |
!ListModelView::Renderer methodsFor:'displaying'! |
1918 |
||
1919 |
display:anItem atX:xLeft y:yTop lineHeight:h |
|
4703 | 1920 |
"display the item on the view" |
1921 |
||
1922 |
"/ obsolete - for backward compatibility |
|
1923 |
self display:anItem atX:xLeft y:yTop lineHeight:h isHighlightedAsSelected:false |
|
1924 |
! |
|
1925 |
||
1926 |
display:anItem atX:xLeft y:yTop lineHeight:h isHighlightedAsSelected:isHighlightedAsSelected |
|
2352 | 1927 |
"display the item on the view |
1928 |
" |
|
4707 | 1929 |
|x0 y0 label labelShown| |
2352 | 1930 |
|
1931 |
x0 := xLeft. |
|
1932 |
y0 := yTop. |
|
1933 |
||
1934 |
anItem isHierarchicalItem ifTrue:[ |
|
4752 | 1935 |
(anItem class whichClassIncludesSelector:#displayOn:x:y:h:) ~~ AbstractHierarchicalItem ifTrue:[ |
4720 | 1936 |
"/ it has a redefined displayOn method. |
4706 | 1937 |
Transcript showCR:'please define #displayOn:x:y:h:isHighlightedAsSelected: in ',anItem class name. |
1938 |
anItem displayOn:view x:x0 y:y0 h:h |
|
1939 |
] ifFalse:[ |
|
1940 |
anItem displayOn:view x:x0 y:y0 h:h isHighlightedAsSelected:isHighlightedAsSelected |
|
1941 |
]. |
|
2352 | 1942 |
] ifFalse:[ |
4703 | 1943 |
anItem isNil ifTrue:[^ self]. |
1944 |
||
1945 |
y0 := y0 - (((self heightFor:anItem) + 1 - h) // 2). |
|
1946 |
label := anItem. |
|
1947 |
||
1948 |
label isImageOrForm ifFalse:[ |
|
1949 |
label isNumber ifTrue:[ |
|
1950 |
label := label printString |
|
1951 |
]. |
|
1952 |
y0 := y0 + view font ascent |
|
1953 |
]. |
|
4707 | 1954 |
labelShown := label. |
1955 |
label isText ifTrue:[ |
|
1956 |
isHighlightedAsSelected ifTrue:[ |
|
1957 |
(label hasChangeOfEmphasis) ifTrue:[ |
|
1958 |
labelShown := Text string:label string emphasisCollection:label emphasis asArray. |
|
1959 |
labelShown emphasisAllRemove:#color. |
|
1960 |
]. |
|
1961 |
]. |
|
1962 |
]. |
|
1963 |
labelShown displayOn:view x:x0 y:y0 |
|
2352 | 1964 |
]. |
2644 | 1965 |
! |
1966 |
||
1967 |
postRedrawX:damageX y:yStartOrYDamage w:damageWidth from:startOrNil to:stopOrNil |
|
1968 |
"called after redraw of the items in range from start to stop is done; |
|
1969 |
if no items are damaged, start and stop is set to nil. |
|
1970 |
" |
|
1971 |
! |
|
1972 |
||
1973 |
validateDrawableItemsFrom:start to:stop |
|
1974 |
"called before drawing items from start to stop; if the method returns false |
|
1975 |
nothing will be drawn and a invalidate is pushed on the event queue. |
|
1976 |
On default true is returned. |
|
1977 |
" |
|
1978 |
^ true |
|
2352 | 1979 |
! ! |
1980 |
||
1981 |
!ListModelView::Renderer methodsFor:'instance creation'! |
|
1982 |
||
1983 |
forView:aView |
|
1984 |
view := aView. |
|
2644 | 1985 |
view shown ifTrue:[ self mapped ]. |
2643 | 1986 |
! |
1987 |
||
1988 |
mapped |
|
1989 |
"called if the view is mapped; can be redefined by subclass |
|
1990 |
" |
|
1991 |
! |
|
1992 |
||
1993 |
release |
|
1994 |
"called if the view is gone; can be redefined by subclass |
|
1995 |
" |
|
2352 | 1996 |
! ! |
1997 |
||
1998 |
!ListModelView::Renderer methodsFor:'queries-dimensions'! |
|
1999 |
||
2000 |
heightFor:anItem |
|
2001 |
"returns the height of an item on the view |
|
2002 |
" |
|
2003 |
^ anItem heightOn:view |
|
2004 |
! |
|
2005 |
||
2643 | 2006 |
maxItemWidthOrNil |
2007 |
"returns the maximum item width for drawing or nil |
|
2008 |
if unspecified (the default); used for cliping |
|
2009 |
" |
|
2010 |
^ nil |
|
2011 |
! |
|
2012 |
||
2352 | 2013 |
widthFor:anItem |
2014 |
"returns the width of an item on the view |
|
2015 |
" |
|
2016 |
^ anItem widthOn:view |
|
2644 | 2017 |
! |
2018 |
||
2019 |
widthOfWidestLineBetween:firstLine and:lastLine |
|
2020 |
"returns the width of the longest line in pixels in a range; if the rendere |
|
2021 |
cannot compute the width, nil is returned (the default). |
|
2022 |
" |
|
2023 |
^ nil |
|
2352 | 2024 |
! ! |
2025 |
||
3717 | 2026 |
!ListModelView::TableRenderer class methodsFor:'defaults'! |
2027 |
||
2028 |
dragCursor |
|
2029 |
"returns the cursor used to highliggt the drag can start operation |
|
2030 |
" |
|
2031 |
^ Cursor leftRightArrow |
|
2032 |
! |
|
2033 |
||
2034 |
separatorOneDColor |
|
2035 |
"answer the color used for drawing separators" |
|
2036 |
||
4645 | 2037 |
^ Color lightGray |
3717 | 2038 |
! ! |
2039 |
||
2040 |
!ListModelView::TableRenderer methodsFor:'accessing'! |
|
2041 |
||
2042 |
columnDescriptors:aSeqOfColumnSpecs |
|
2043 |
"setup column descriptions for a sequence of DataSetColumnSpec's but still keep |
|
2044 |
the receiver which provides the selectors called by the DataSetColumnSpec. |
|
2045 |
||
2046 |
If the receiver is nil, the item into the list is invoked" |
|
2047 |
||
2048 |
self columnDescriptors:aSeqOfColumnSpecs receiver:receiver. |
|
2049 |
! |
|
2050 |
||
2051 |
columnDescriptors:aSeqOfColumnSpecs receiver:aReceiver |
|
2052 |
"setup column descriptions for a sequence of DataSetColumnSpec's and the |
|
2053 |
receiver which provides the selectors called by the DataSetColumnSpec. |
|
2054 |
||
2055 |
If the receiver is nil, the item into the list is invoked" |
|
2056 |
||
2057 |
receiver := aReceiver. |
|
2058 |
||
2059 |
minimumRequiredColumnHeight := 0. |
|
2060 |
||
2061 |
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
|
2062 |
columnDescriptors := #(). |
3717 | 2063 |
] 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
|
2064 |
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
|
2065 |
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
|
2066 |
]. |
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
|
2067 |
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
|
2068 |
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
|
2069 |
|
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 |
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
|
2071 |
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
|
2072 |
]. |
3717 | 2073 |
]. |
2074 |
hasFixedItemWidth := attributes at:#hasFixedItemWidth ifAbsent:[false]. |
|
2075 |
||
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
|
2076 |
self initializeSplitbars. |
3717 | 2077 |
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
|
2078 |
|
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
|
2079 |
"Modified: / 24-04-2013 / 13:32:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2080 |
! |
2081 |
||
2082 |
numberOfColumns |
|
2083 |
"answer the numbers of columns excluding the items row" |
|
2084 |
||
2085 |
^ columnDescriptors size |
|
4204
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2086 |
! |
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2087 |
|
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2088 |
xSplitbars |
efb428640011
class: ListModelView::TableRenderer
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4201
diff
changeset
|
2089 |
^ xSplitbars |
3717 | 2090 |
! ! |
2091 |
||
2092 |
!ListModelView::TableRenderer methodsFor:'accessing-look'! |
|
2093 |
||
2094 |
defaultWidthForItem |
|
2095 |
"answer the default witdth of the item before the first column" |
|
2096 |
||
2097 |
^ attributes at:#defaultWidthForItem ifAbsent:[ 100 ]. |
|
2098 |
! |
|
2099 |
||
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2100 |
defaultWidthForItem:anIntegerOrFloat |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2101 |
"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
|
2102 |
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
|
2103 |
- 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
|
2104 |
- 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
|
2105 |
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
|
2106 |
" |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2107 |
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
|
2108 |
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
|
2109 |
]. |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2110 |
^ 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
|
2111 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2112 |
"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
|
2113 |
! |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2114 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2115 |
defaultWidthForItemInPixels |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2116 |
"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
|
2117 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2118 |
| w | |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2119 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2120 |
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
|
2121 |
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
|
2122 |
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
|
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 |
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2125 |
|
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2126 |
"Created: / 12-08-2013 / 12:16:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2127 |
! |
2128 |
||
2129 |
noAutoResizeForRowOfItems |
|
2130 |
"the first row which keeps the items are not automaticaly resized |
|
2131 |
when width of items changed" |
|
2132 |
||
2133 |
hasFixedItemWidth := true. |
|
2134 |
attributes at:#hasFixedItemWidth put:true. |
|
2135 |
! |
|
2136 |
||
2137 |
separatorOneDColor |
|
2138 |
"answer the color used for drawing separators" |
|
2139 |
||
2140 |
separatorOneDColor isNil ifTrue:[ |
|
3728 | 2141 |
separatorOneDColor := self class separatorOneDColor. |
2142 |
||
2143 |
(view notNil and:[view realized]) ifTrue:[ |
|
2144 |
separatorOneDColor := separatorOneDColor onDevice:(view device). |
|
2145 |
]. |
|
3717 | 2146 |
]. |
2147 |
^ separatorOneDColor |
|
2148 |
! |
|
2149 |
||
2150 |
showHorizontalSeparators |
|
2151 |
"answer true if horizontal separators are drawn" |
|
2152 |
||
2153 |
^ attributes at:#showHorizontalSeparators ifAbsent:[ true ]. |
|
2154 |
! |
|
2155 |
||
2156 |
showHorizontalSeparators:aBoolean |
|
2157 |
"set true if horizontal separators are drawn" |
|
2158 |
||
2159 |
attributes at:#showHorizontalSeparators put:aBoolean. |
|
2160 |
! |
|
2161 |
||
2162 |
showHorizontalSeparatorsForItem |
|
2163 |
"answer true if horizontal separators is drawn for the item row" |
|
2164 |
||
2165 |
^ attributes at:#showHorizontalSeparatorsForItem ifAbsent:[ true ]. |
|
2166 |
! |
|
2167 |
||
2168 |
showHorizontalSeparatorsForItem:aBoolean |
|
2169 |
"set true if horizontal separators is drawn for the item row" |
|
2170 |
||
2171 |
attributes at:#showHorizontalSeparatorsForItem put:aBoolean. |
|
2172 |
! |
|
2173 |
||
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
|
2174 |
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
|
2175 |
"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
|
2176 |
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
|
2177 |
|
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 |
^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
|
2179 |
|
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 |
"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
|
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 |
|
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 |
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
|
2184 |
"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
|
2185 |
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
|
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 |
| 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
|
2188 |
|
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 |
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
|
2190 |
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
|
2191 |
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
|
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 |
"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
|
2194 |
! |
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 |
|
3717 | 2196 |
showVerticalSplitbars |
2197 |
"answer true if vertical separators are drawn" |
|
2198 |
||
2199 |
^ attributes at:#showVerticalSplitbars ifAbsent:[ true ]. |
|
2200 |
! |
|
2201 |
||
2202 |
showVerticalSplitbars:aBoolean |
|
2203 |
"set true if vertical separators are drawn" |
|
2204 |
||
2205 |
attributes at:#showVerticalSplitbars put:aBoolean. |
|
2206 |
! |
|
2207 |
||
2208 |
showVerticalSplitbarsBelowContents |
|
2209 |
"answer true if the vertical separators are drawn below last row" |
|
2210 |
||
2211 |
^ attributes at:#showVerticalSplitbarsBelowContents ifAbsent:[ false ]. |
|
2212 |
! |
|
2213 |
||
2214 |
showVerticalSplitbarsBelowContents:aBoolean |
|
2215 |
"set true if the vertical separators are drawn below last row" |
|
2216 |
||
2217 |
attributes at:#showVerticalSplitbarsBelowContents put:aBoolean. |
|
2218 |
! |
|
2219 |
||
2220 |
splitbarInset |
|
2221 |
"returns the horizontal left and right inset of the splitbar" |
|
2222 |
||
2223 |
^ 2 |
|
2224 |
! |
|
2225 |
||
2226 |
textStartLeft |
|
2227 |
"used when drawing the last separator; |
|
2228 |
workaround when drawing the selection frame" |
|
2229 |
||
2230 |
^ 2 |
|
2231 |
! ! |
|
2232 |
||
2233 |
!ListModelView::TableRenderer methodsFor:'actions'! |
|
2234 |
||
2235 |
moveSplitbarAt:aSepIndex toAbsoluteX:x |
|
2236 |
"move the position of the separator at an index to absolute position x; |
|
2237 |
used to drag splitbars" |
|
2238 |
||
2239 |
|xOld xNew xPrv deltaX xAbsoluteOfFirstSplitbar| |
|
2240 |
||
2241 |
aSepIndex == 1 ifTrue:[ |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2242 |
hasFixedItemWidth := true. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2243 |
xPrv := view margin. |
3717 | 2244 |
] ifFalse:[ |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2245 |
xPrv := xSplitbars at:(aSepIndex - 1). |
3717 | 2246 |
]. |
2247 |
||
2248 |
aSepIndex == 1 ifTrue:[ |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2249 |
hasFixedItemWidth := true. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2250 |
xPrv := view margin. |
3717 | 2251 |
] ifFalse:[ |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2252 |
xPrv := xSplitbars at:(aSepIndex - 1). |
3717 | 2253 |
]. |
2254 |
xOld := xSplitbars at:aSepIndex. |
|
2255 |
xNew := x max:xPrv. |
|
2256 |
||
2257 |
deltaX := xNew - xOld. |
|
2258 |
deltaX = 0 ifTrue:[ ^ self ]. |
|
2259 |
||
2260 |
xAbsoluteOfFirstSplitbar := xSplitbars at:1. |
|
2261 |
||
2262 |
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
|
2263 |
xSplitbars at:sepIdx put:(sepX + deltaX). |
3717 | 2264 |
]. |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2265 |
aSepIndex ~~ 1 ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2266 |
(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
|
2267 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2268 |
|
3717 | 2269 |
view setWidthOfContents:(xSplitbars last). |
2270 |
||
2271 |
view shown ifTrue:[ |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2272 |
|damage width height orgX| |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2273 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2274 |
view windowGroup processRealExposeEventsFor:self. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2275 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2276 |
width := view width. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2277 |
height := view height. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2278 |
orgX := view viewOrigin x. |
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 |
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
|
2281 |
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
|
2282 |
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
|
2283 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2284 |
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
|
2285 |
deltaX := xOld - xNew. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2286 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2287 |
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
|
2288 |
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
|
2289 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2290 |
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
|
2291 |
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
|
2292 |
] ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2293 |
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
|
2294 |
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
|
2295 |
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
|
2296 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2297 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2298 |
xNew > xPrv ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2299 |
"/ 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
|
2300 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2301 |
xAbsoluteOfFirstSplitbar := xAbsoluteOfFirstSplitbar - self splitbarInset. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2302 |
xPrv := (xPrv max:xAbsoluteOfFirstSplitbar). |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2303 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2304 |
xNew > xPrv ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2305 |
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
|
2306 |
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
|
2307 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2308 |
]. |
3717 | 2309 |
]. |
2310 |
view contentsChanged. |
|
4217
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 |
"Modified: / 07-05-2013 / 20:55:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2313 |
! ! |
2314 |
||
2315 |
!ListModelView::TableRenderer methodsFor:'change & update'! |
|
2316 |
||
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2317 |
sizeChanged:how |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2318 |
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
|
2319 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2320 |
"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
|
2321 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2322 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2323 |
sizeChangedDelayed:how |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2324 |
self initializeSplitbars. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2325 |
self splitbarsChanged. |
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 |
"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
|
2328 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2329 |
|
3717 | 2330 |
splitbarsChanged |
2331 |
"called if the splitbars has changed; recompute the width of contents" |
|
2332 |
||
2333 |
view notNil ifTrue:[ |
|
3728 | 2334 |
|newWidth oldWidth| |
2335 |
||
2336 |
oldWidth := view getWidthOfContents. |
|
2337 |
||
2338 |
oldWidth notNil ifTrue:[ |
|
2339 |
newWidth := xSplitbars last. |
|
2340 |
||
2341 |
newWidth ~= oldWidth ifTrue:[ |
|
2342 |
view setWidthOfContents:newWidth. |
|
2343 |
view contentsChanged. |
|
2344 |
]. |
|
2345 |
view invalidate. |
|
2346 |
]. |
|
3717 | 2347 |
]. |
2348 |
! |
|
2349 |
||
2350 |
withinUpdateFromListDo:aBlock |
|
2351 |
"handle an change & update within the view" |
|
2352 |
||
2353 |
|xAbs| |
|
2354 |
||
2355 |
xAbs := xSplitbars last. |
|
2356 |
super withinUpdateFromListDo:aBlock. |
|
2357 |
||
2358 |
xAbs ~~ xSplitbars last ifTrue:[ |
|
3728 | 2359 |
self splitbarsChanged |
3717 | 2360 |
]. |
2361 |
! ! |
|
2362 |
||
2363 |
!ListModelView::TableRenderer methodsFor:'displaying'! |
|
2364 |
||
2365 |
drawColumnsFrom:start to:stop x:xDmg y:yStart w:wDmg |
|
2366 |
"draw columns from start to stop. |
|
2367 |
if the start/stop index is nil, than no row is affected by the damage." |
|
2368 |
||
2369 |
|xNxt xMax xTrs clip y0 y1 x0 x1 hgFgColor hgBgColor fgColor bgColor colInset |
|
3722 | 2370 |
shownSelected numSplitbars| |
2371 |
||
2372 |
start isNil ifTrue:[^ self]. |
|
2373 |
numSplitbars := xSplitbars size. |
|
2374 |
numSplitbars > 1 ifFalse:[^ self]. |
|
3717 | 2375 |
|
2376 |
xTrs := view viewOrigin x. |
|
2377 |
xMax := xDmg + wDmg. |
|
2378 |
xNxt := xSplitbars first - xTrs. |
|
2379 |
||
2380 |
xNxt >= xMax ifTrue:[^ self]. |
|
2381 |
||
2382 |
view hasSelection ifTrue:[ |
|
3909 | 2383 |
hgFgColor := view hilightForegroundColor. |
2384 |
hgBgColor := view hilightBackgroundColor. |
|
3717 | 2385 |
]. |
3728 | 2386 |
fgColor := view foregroundColor. |
3717 | 2387 |
bgColor := view backgroundColor. |
4478 | 2388 |
clip := view clippingBoundsOrNil. |
3717 | 2389 |
|
2390 |
clip isNil ifTrue:[ |
|
3909 | 2391 |
clip := Rectangle left:xDmg top:yStart width:wDmg height:(view height - yStart). |
3717 | 2392 |
]. |
2393 |
colInset := self splitbarInset. |
|
2394 |
||
3722 | 2395 |
2 to:numSplitbars do:[:anIndex| |
3909 | 2396 |
|clipLft clipRgt colWdth colDesc| |
2397 |
||
2398 |
xNxt < xMax ifFalse:[^ self]. |
|
2399 |
||
2400 |
x0 := xNxt. |
|
2401 |
xNxt := (xSplitbars at:anIndex) - xTrs. |
|
2402 |
x1 := xNxt. |
|
2403 |
||
2404 |
"/ workaround due to drawing the selection frame |
|
2405 |
anIndex == numSplitbars ifTrue:[ x1 := x1 + self textStartLeft ]. |
|
2406 |
||
2407 |
colDesc := columnDescriptors at:(anIndex - 1) ifAbsent:[ ^ self ]. "/ can give up... |
|
2408 |
clipLft := x0 max:xDmg. |
|
2409 |
clipRgt := x1 min:xMax. |
|
2410 |
colWdth := x1 - x0. |
|
2411 |
||
2412 |
(colWdth > 2 and:[clipLft < clipRgt]) ifTrue:[ |
|
2413 |
clip := clip copy. |
|
2414 |
clip setLeft:clipLft. |
|
2415 |
clip right:clipRgt. |
|
2416 |
view clippingRectangle:clip. |
|
2417 |
y1 := yStart. |
|
2418 |
||
2419 |
start to:stop do:[:aRowNr| |
|
2420 |
|recv| |
|
2421 |
||
2422 |
y0 := y1. |
|
2423 |
y1 := view yVisibleOfLine:(aRowNr + 1). |
|
2424 |
||
2425 |
recv := receiver. |
|
2426 |
recv isNil ifTrue:[ recv := view at:aRowNr ifAbsent:nil ]. |
|
2427 |
||
2428 |
recv notNil ifTrue:[ |
|
2429 |
(hgFgColor notNil and:[view isInSelection:aRowNr]) ifTrue:[ |
|
2430 |
shownSelected := true. |
|
2431 |
view paint:hgFgColor on:hgBgColor |
|
2432 |
] ifFalse:[ |
|
2433 |
shownSelected := false. |
|
2434 |
view paint:fgColor on:bgColor. |
|
2435 |
]. |
|
2436 |
colDesc |
|
2437 |
drawRowAt:aRowNr |
|
2438 |
shownSelected:shownSelected |
|
2439 |
receiver:recv |
|
2440 |
x:x0 + colInset |
|
2441 |
y:y0 |
|
2442 |
w:colWdth - colInset - colInset |
|
2443 |
h:(y1 - y0) on:view. |
|
2444 |
]. |
|
2445 |
]. |
|
2446 |
]. |
|
3717 | 2447 |
]. |
3909 | 2448 |
|
2449 |
"Modified: / 16-06-2010 / 16:34:32 / cg" |
|
3717 | 2450 |
! |
2451 |
||
2452 |
drawHorizontalSeparatorsX:x y:y w:w from:start to:stop |
|
2453 |
"draw horizontal seperators from start to stop. |
|
2454 |
if the start/stop index is nil, than no row is affected by the damage." |
|
2455 |
||
2456 |
|x1 ySep clipRec x0| |
|
2457 |
||
2458 |
start isNil ifTrue:[ ^ self ]. |
|
2459 |
||
2460 |
"/ workaround due to drawing the selection frame |
|
2461 |
x1 := self xVisibleOfLastSplitbar + self textStartLeft. |
|
2462 |
||
2463 |
x1 := x1 min:(x + w). |
|
2464 |
x1 <= x ifTrue:[^ self]. |
|
2465 |
||
2466 |
x0 := x. |
|
2467 |
||
2468 |
self showHorizontalSeparatorsForItem ifFalse:[ |
|
3728 | 2469 |
x0 := x0 max:(self xVisibleOfSplitbarAt:1). |
2470 |
x1 <= x0 ifTrue:[^ self]. |
|
3717 | 2471 |
]. |
2472 |
clipRec := Rectangle left:x0 top:0 right:x1 bottom:(view height). |
|
2473 |
||
2474 |
view clippingRectangle:clipRec. |
|
2475 |
view paint:(self separatorOneDColor). |
|
2476 |
||
2477 |
start to:stop do:[:aRowNr| |
|
3728 | 2478 |
ySep := (view yVisibleOfLine:(aRowNr + 1)) - 1. |
2479 |
view displayLineFromX:x0 y:ySep toX:x1 y:ySep. |
|
3717 | 2480 |
]. |
2481 |
! |
|
2482 |
||
2483 |
drawVerticalSplitbarsX:x0 y:y0 w:w from:start to:stop |
|
2484 |
"draw vertical splitbars" |
|
2485 |
||
2486 |
|x x1 vX y1 clipRec nrOfSep| |
|
2487 |
||
2488 |
nrOfSep := xSplitbars size. |
|
2489 |
nrOfSep == 0 ifTrue:[^ self]. |
|
2490 |
||
2491 |
"/ workaround for textStartTop |
|
2492 |
||
2493 |
y1 := view height. |
|
2494 |
||
2495 |
self showVerticalSplitbarsBelowContents ifFalse:[ |
|
3728 | 2496 |
stop isNil ifTrue:[^ self]. |
2497 |
||
2498 |
y1 := y1 min:(view yVisibleOfLine:(stop + 1)). |
|
2499 |
y1 <= y0 ifTrue:[ ^ self ]. |
|
3717 | 2500 |
]. |
2501 |
x1 := x0 + w. |
|
2502 |
vX := view viewOrigin x. |
|
2503 |
||
2504 |
xSplitbars keysAndValuesDo:[:anIndex :physY| |
|
3728 | 2505 |
(self showVerticalSplitbarAt:anIndex) ifTrue:[ |
2506 |
x := physY - vX. |
|
2507 |
x > x1 ifTrue:[^ self]. "/ can giveup - behind max x1 |
|
2508 |
||
2509 |
anIndex == nrOfSep ifTrue:[ |
|
2510 |
"/ workaround due to drawing the selection frame |
|
2511 |
x := x + self textStartLeft |
|
2512 |
]. |
|
2513 |
x >= x0 ifTrue:[ |
|
2514 |
clipRec isNil ifTrue:[ |
|
2515 |
"/ first time to setup clipping and colors |
|
2516 |
||
2517 |
clipRec := Rectangle left:x0 top:y0 right:x1 bottom:y1. |
|
2518 |
view clippingRectangle:clipRec. |
|
2519 |
view paint:(self separatorOneDColor). |
|
2520 |
]. |
|
2521 |
view displayLineFromX:x y:y0 toX:x y:y1. |
|
2522 |
]. |
|
2523 |
]. |
|
3717 | 2524 |
]. |
2525 |
! |
|
2526 |
||
2527 |
postRedrawX:x y:y w:w from:start to:stop |
|
2528 |
"draw columns and than the splitbars" |
|
2529 |
||
2530 |
self drawColumnsFrom:start to:stop x:x y:y w:w. |
|
2531 |
||
2532 |
self showHorizontalSeparators ifTrue:[ |
|
3728 | 2533 |
self drawHorizontalSeparatorsX:x y:y w:w from:start to:stop. |
3717 | 2534 |
]. |
2535 |
self showVerticalSplitbars ifTrue:[ |
|
3728 | 2536 |
self drawVerticalSplitbarsX:x y:y w:w from:start to:stop. |
3717 | 2537 |
]. |
2538 |
! |
|
2539 |
||
2540 |
validateDrawableItemsFrom:start to:stop |
|
2541 |
"called before drawing the items in range from start to stop; the |
|
2542 |
renderer can perform some tests whether the draw operation might |
|
2543 |
fail; width, ... might change during draw. |
|
2544 |
If a test failed, the renderer should repair the failed test and |
|
2545 |
return false. In this case a full redraw is done. |
|
2546 |
On default true is returned." |
|
2547 |
||
2548 |
|xLastOld xLastNew| |
|
2549 |
||
2550 |
xLastOld := xSplitbars last. |
|
2551 |
xLastNew := self widthOfWidestLineBetween:start and:stop. |
|
2552 |
||
2553 |
xLastNew == xLastOld ifTrue:[^ true]. |
|
2554 |
||
2555 |
self splitbarsChanged. |
|
2556 |
^ false |
|
2557 |
! ! |
|
2558 |
||
2559 |
!ListModelView::TableRenderer methodsFor:'enumerating'! |
|
2560 |
||
3722 | 2561 |
columnDescriptorsDo:aOneArgBlock |
2562 |
columnDescriptors size > 0 ifTrue:[ |
|
3728 | 2563 |
columnDescriptors do:aOneArgBlock. |
3722 | 2564 |
]. |
2565 |
! |
|
2566 |
||
2567 |
columnDescriptorsKeysAndValuesDo:aTwoArgBlock |
|
2568 |
||
2569 |
columnDescriptors size > 0 ifTrue:[ |
|
3728 | 2570 |
columnDescriptors keysAndValuesDo:aTwoArgBlock. |
3722 | 2571 |
]. |
2572 |
! |
|
2573 |
||
3717 | 2574 |
xSplitbarsDo:aOneArgblock |
2575 |
"evaluate a block on each x splitbar position |
|
2576 |
" |
|
2577 |
^ xSplitbars do:aOneArgblock. |
|
2578 |
! |
|
2579 |
||
2580 |
xSplitbarsKeysAndValuesDo:aTwoArgblock |
|
2581 |
"evaluate a block on each x splitbar index and position |
|
2582 |
" |
|
2583 |
^ xSplitbars keysAndValuesDo:aTwoArgblock. |
|
2584 |
! ! |
|
2585 |
||
2586 |
!ListModelView::TableRenderer methodsFor:'event processing'! |
|
2587 |
||
2588 |
addEventHook |
|
2589 |
"add event hook to window group" |
|
2590 |
||
2591 |
|winGrp| |
|
2592 |
||
2593 |
view notNil ifTrue:[ |
|
3728 | 2594 |
winGrp := view windowGroup. |
2595 |
||
2596 |
winGrp notNil ifTrue:[ |
|
2597 |
view enableMotionEvents. |
|
2598 |
winGrp addPreEventHook:self. |
|
2599 |
]. |
|
3717 | 2600 |
]. |
2601 |
! |
|
2602 |
||
2603 |
processEvent:ev |
|
2604 |
"only handled if drag splitbar is enabled" |
|
2605 |
||
4168 | 2606 |
<resource: #keyboard (#Escape )> |
2607 |
||
3717 | 2608 |
ev isInputEvent ifFalse:[^ false]. |
2609 |
||
2610 |
dragOperation notNil ifTrue:[ |
|
3909 | 2611 |
dragOperation value:ev. |
2612 |
^ true |
|
3717 | 2613 |
]. |
2614 |
||
2615 |
(view shown |
|
2616 |
and:[ev view == view |
|
2617 |
and:[(ev isButtonPressEvent or:[ev isButtonMotionEvent]) |
|
3909 | 2618 |
and:[((ev button ~= 2) and:[ev button ~= #menu])]]]) ifTrue:[ |
2619 |
|splitBarColIndex colIndex phyX colX descr| |
|
2620 |
||
2621 |
splitBarColIndex := self xVisibleToSplitbar:(ev x). |
|
2622 |
||
2623 |
(splitBarColIndex > 0 and:[self showVerticalSplitbarsBelowContents not]) ifTrue:[ |
|
2624 |
"/ test whether y is below contents.... |
|
2625 |
ev y > (view heightOfContents - view viewOrigin y) ifTrue:[ |
|
2626 |
splitBarColIndex := 0 |
|
2627 |
]. |
|
2628 |
]. |
|
2629 |
||
2630 |
ev isButtonPressEvent ifTrue:[ |
|
2631 |
splitBarColIndex < 1 ifTrue:[ |
|
2632 |
"/ see if a title-column has been clicked on... |
|
2633 |
colIndex := self xAbsoluteToColumnIndex:(ev x). |
|
2634 |
(colIndex > 0 and:[colIndex <= columnDescriptors size]) ifTrue:[ |
|
2635 |
descr := columnDescriptors at:colIndex. |
|
2636 |
descr := descr dataSetColumnSpec. |
|
2637 |
descr isSortable ifTrue:[ |
|
2638 |
"/ see if clicked in the top-row; sort as appropriate... |
|
2639 |
self breakPoint:#todo. |
|
2640 |
]. |
|
2641 |
]. |
|
2642 |
^ false |
|
2643 |
]. |
|
2644 |
||
2645 |
colX := self xAbsoluteOfSplitbarAt:splitBarColIndex. |
|
2646 |
phyX := ev x. |
|
2647 |
||
2648 |
dragOperation := [:event| |
|
2649 |
event isKeyEvent ifTrue:[ |
|
2650 |
event rawKey == #Escape ifTrue:[ |
|
2651 |
dragOperation := nil. |
|
2652 |
self moveSplitbarAt:splitBarColIndex toAbsoluteX:colX. |
|
2653 |
]. |
|
2654 |
] ifFalse:[ |
|
2655 |
event isButtonPressEvent ifTrue:[ |
|
2656 |
dragOperation := nil. |
|
2657 |
self moveSplitbarAt:splitBarColIndex toAbsoluteX:colX. |
|
2658 |
]. |
|
2659 |
event isButtonReleaseEvent ifTrue:[ |
|
2660 |
dragOperation := nil. |
|
2661 |
]. |
|
2662 |
event isButtonMotionEvent ifTrue:[ |
|
2663 |
(view sensor hasExposeEventFor:nil) ifFalse:[ |
|
2664 |
self |
|
2665 |
moveSplitbarAt:splitBarColIndex |
|
2666 |
toAbsoluteX:(colX + (event x) - phyX). |
|
2667 |
]. |
|
2668 |
]. |
|
2669 |
]. |
|
2670 |
]. |
|
2671 |
^ true |
|
2672 |
]. |
|
2673 |
||
2674 |
splitBarColIndex == 0 ifTrue:[ |
|
2675 |
savedCursor notNil ifTrue:[ |
|
2676 |
view cursor:savedCursor. |
|
2677 |
savedCursor := nil. |
|
2678 |
]. |
|
2679 |
] ifFalse:[ |
|
2680 |
savedCursor isNil ifTrue:[ |
|
2681 |
savedCursor := view cursor. |
|
2682 |
view cursor:dragCursor. |
|
2683 |
]. |
|
2684 |
]. |
|
3717 | 2685 |
]. |
2686 |
^ false |
|
3909 | 2687 |
|
2688 |
"Modified: / 16-06-2010 / 16:35:41 / cg" |
|
3717 | 2689 |
! |
2690 |
||
2691 |
removeEventHook |
|
2692 |
"release my event hook" |
|
2693 |
||
2694 |
|winGrp| |
|
2695 |
||
2696 |
view notNil ifTrue:[ |
|
3728 | 2697 |
winGrp := view windowGroup. |
2698 |
winGrp notNil ifTrue:[ winGrp removePreEventHook:self ]. |
|
3717 | 2699 |
]. |
2700 |
! ! |
|
2701 |
||
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
|
2702 |
!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
|
2703 |
|
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
|
2704 |
initializeSplitbars |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2705 |
| 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
|
2706 |
|
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 |
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
|
2708 |
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
|
2709 |
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
|
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 |
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
|
2712 |
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
|
2713 |
|
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2714 |
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
|
2715 |
|
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
|
2716 |
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
|
2717 |
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
|
2718 |
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
|
2719 |
]. |
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 |
|
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
|
2721 |
"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
|
2722 |
"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
|
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 |
|
3717 | 2725 |
!ListModelView::TableRenderer methodsFor:'instance creation'! |
2726 |
||
2727 |
forView:aView |
|
2728 |
"setup instance for a view; |
|
2729 |
setup my default columnDescription" |
|
2730 |
||
2731 |
attributes isNil ifTrue:[ |
|
3728 | 2732 |
attributes := IdentityDictionary new. |
3717 | 2733 |
]. |
2734 |
self columnDescriptors:nil. |
|
2735 |
super forView:aView. |
|
2736 |
! |
|
2737 |
||
2738 |
mapped |
|
2739 |
"install event hook and enable motion events |
|
2740 |
" |
|
2741 |
view notNil ifTrue:[ |
|
3728 | 2742 |
dragCursor isNil ifTrue:[ |
2743 |
dragCursor := self class dragCursor onDevice:(view device). |
|
2744 |
]. |
|
2745 |
separatorOneDColor notNil ifTrue:[ |
|
2746 |
separatorOneDColor := separatorOneDColor onDevice:(view device). |
|
2747 |
]. |
|
2748 |
self isDragEnabled ifTrue:[ self addEventHook ]. |
|
3717 | 2749 |
]. |
2750 |
! |
|
2751 |
||
2752 |
release |
|
2753 |
"release event hook |
|
2754 |
" |
|
2755 |
self removeEventHook. |
|
2756 |
super release. |
|
2757 |
! ! |
|
2758 |
||
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2759 |
!ListModelView::TableRenderer methodsFor:'private'! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2760 |
|
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2761 |
computeColumnWidthsWithXOffset: xoffset |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2762 |
| 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
|
2763 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2764 |
done := false. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2765 |
nCols := columnDescriptors size. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2766 |
nCols == 0 ifTrue:[ ^#() ]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2767 |
widthsFixed := Array new: nCols. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2768 |
widths := Array new: nCols. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2769 |
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
|
2770 |
(xoffset) - |
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2771 |
(self splitbarInset * nCols * 2) - |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2772 |
(nCols) "splitbar width". |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2773 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2774 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2775 |
[ done ] whileFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2776 |
done := true. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2777 |
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
|
2778 |
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
|
2779 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2780 |
remainingW := viewW. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2781 |
flexSum := 0.0. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2782 |
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
|
2783 |
(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
|
2784 |
remainingW := remainingW - ws. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2785 |
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
|
2786 |
] ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2787 |
ws isFloat ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2788 |
flexSum := flexSum + ws. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2789 |
] |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2790 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2791 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2792 |
remainingW := remainingW max: 0. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2793 |
"/ 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
|
2794 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2795 |
flexSum > 0 ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2796 |
flexUnit := remainingW / flexSum. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2797 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2798 |
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
|
2799 |
(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
|
2800 |
w := (flexUnit * wflex) floor. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2801 |
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
|
2802 |
w < wmin ifTrue:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2803 |
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
|
2804 |
done := false. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2805 |
] ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2806 |
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
|
2807 |
] |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2808 |
] |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2809 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2810 |
]. |
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 |
^widths |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2813 |
|
4323
c05e731505fb
Support for relative width settings for first column in TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4319
diff
changeset
|
2814 |
"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
|
2815 |
! ! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
2816 |
|
3717 | 2817 |
!ListModelView::TableRenderer methodsFor:'private accessing'! |
2818 |
||
2819 |
columnAlignmentAt:aColNr |
|
2820 |
^ (columnDescriptors at:aColNr) alignment |
|
2821 |
! |
|
2822 |
||
2823 |
defaultColumnWidthAt:aColIndex |
|
2824 |
^ (columnDescriptors at:aColIndex) defaultColumnWidth |
|
2825 |
! |
|
2826 |
||
2827 |
showVerticalSplitbarAt:aColIndex |
|
3728 | 2828 |
aColIndex > 1 ifTrue:[ |
2829 |
^ (columnDescriptors at:(aColIndex - 1)) showVerticalSplitbar |
|
3717 | 2830 |
]. |
2831 |
^ true |
|
2832 |
! ! |
|
2833 |
||
2834 |
!ListModelView::TableRenderer methodsFor:'queries-behavior'! |
|
2835 |
||
2836 |
isDragEnabled |
|
2837 |
"answer true if drag of separators is enabled" |
|
2838 |
||
2839 |
^ attributes at:#isDragEnabled ifAbsent:[ true ]. |
|
2840 |
! |
|
2841 |
||
2842 |
isDragEnabled:aBoolean |
|
2843 |
"answer true if drag of separators is enabled" |
|
2844 |
||
2845 |
attributes at:#isDragEnabled put:aBoolean. |
|
2846 |
||
2847 |
aBoolean ifTrue:[ self addEventHook ] |
|
3728 | 2848 |
ifFalse:[ self removeEventHook ]. |
3717 | 2849 |
! ! |
2850 |
||
2851 |
!ListModelView::TableRenderer methodsFor:'queries-dimensions'! |
|
2852 |
||
4198 | 2853 |
boundingBoxForCellAtXAbsolute:x yAbsolute:y |
2854 |
||
2855 |
|xNxt xTrs y0 y1 x0 x1 colInset colNr rowNr numSplitbars| |
|
2856 |
||
2857 |
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
|
2858 |
numSplitbars > 1 ifFalse:[^ nil]. |
4198 | 2859 |
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
|
2860 |
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
|
2861 |
rowNr := view yAbsoluteToLineNr: y. |
4198 | 2862 |
|
2863 |
||
2864 |
xTrs := view viewOrigin x. |
|
2865 |
xNxt := xSplitbars first - xTrs. |
|
2866 |
colInset := self splitbarInset. |
|
2867 |
||
4199
9e655a8d339f
Workaround stc bug, sigh
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4198
diff
changeset
|
2868 |
colNr ~~ 1 ifTrue:[x0 := (xSplitbars at:colNr - 1)] ifFalse:[x0 := 0]. |
4198 | 2869 |
x1 := (xSplitbars at:colNr) " - xTrs". |
2870 |
||
2871 |
"/ workaround due to drawing the selection frame |
|
2872 |
colNr == numSplitbars ifTrue:[ x1 := x1 + self textStartLeft ]. |
|
2873 |
||
2874 |
||
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2875 |
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
|
2876 |
y1 := view yAbsoluteOfLine:(rowNr + 1). |
4198 | 2877 |
|
2878 |
^ 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
|
2879 |
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
|
2880 |
top: y0 - (view viewOrigin y) |
4198 | 2881 |
width: x1 - x0 - colInset - colInset |
2882 |
height: y1 - y0 - 1 "/Separator line" |
|
2883 |
||
2884 |
"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
|
2885 |
"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
|
2886 |
! |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2887 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
2888 |
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
|
2889 |
^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
|
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 |
"Created: / 18-04-2013 / 10:15:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4198 | 2892 |
! |
2893 |
||
3717 | 2894 |
heightFor:anItem |
2895 |
"returns the height of an item on the view |
|
2896 |
" |
|
2897 |
|h| |
|
2898 |
||
2899 |
h := (anItem heightOn:view) max:minimumRequiredColumnHeight. |
|
2900 |
||
2901 |
"/ add some space for the horizontal separator |
|
2902 |
h := h + self splitbarInset. |
|
2903 |
||
2904 |
h odd ifTrue:[ ^ h + 1 ]. |
|
2905 |
^ h |
|
2906 |
! |
|
2907 |
||
2908 |
maxItemWidthOrNil |
|
2909 |
"returns the maximum item width for drawing; the |
|
2910 |
offset to the first splitbar minus an inset. |
|
2911 |
" |
|
2912 |
^ xSplitbars first - self splitbarInset. |
|
2913 |
! |
|
2914 |
||
2915 |
widthFor:anItem |
|
2916 |
"returns the width of an item on the view including the columns |
|
2917 |
but extracting the hierarchical tree inset. |
|
2918 |
" |
|
2919 |
|xStart xStop xDiff inset| |
|
2920 |
||
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
|
2921 |
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
|
2922 |
|
3717 | 2923 |
xStart := view xAbsoluteOfItem:anItem. |
2924 |
||
2925 |
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
|
2926 |
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
|
2927 |
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
|
2928 |
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
|
2929 |
|
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 |
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
|
2931 |
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
|
2932 |
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
|
2933 |
]. |
3717 | 2934 |
]. |
2935 |
^ 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
|
2936 |
|
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 |
"Modified: / 24-04-2013 / 13:56:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 2938 |
! |
2939 |
||
3723 | 2940 |
widthOfColumn:aColumn |
2941 |
"answer the width of a column or nil" |
|
2942 |
||
2943 |
|index x0 x1| |
|
2944 |
||
2945 |
index := columnDescriptors identityIndexOf:aColumn. |
|
2946 |
||
2947 |
index > 0 ifTrue:[ |
|
3728 | 2948 |
( (x0 := xSplitbars at:index ifAbsent:nil) notNil |
2949 |
and:[(x1 := xSplitbars at:(index + 1) ifAbsent:nil) notNil]) |
|
2950 |
ifTrue:[ |
|
2951 |
^ (x1 - x0 - (2 * (self splitbarInset))) max:0 |
|
2952 |
]. |
|
3723 | 2953 |
]. |
2954 |
^ nil |
|
2955 |
! |
|
2956 |
||
2957 |
widthOfItemColumn |
|
2958 |
"answer the current width of the column which holds the hierarchical |
|
2959 |
item label." |
|
2960 |
||
2961 |
^ xSplitbars at:1. |
|
2962 |
! |
|
2963 |
||
3717 | 2964 |
widthOfWidestLineBetween:firstLine and:lastLine |
2965 |
"returns the width of the longest line in pixels in a range |
|
4858 | 2966 |
- used to optimize scrolling, by limiting the scrolled area; |
2967 |
not for scrollbar or other width related stuff which should be exact." |
|
2968 |
||
3717 | 2969 |
|item| |
2970 |
||
2971 |
hasFixedItemWidth ifFalse:[ |
|
4858 | 2972 |
firstLine to:lastLine do:[:i| |
2973 |
item := view at:i ifAbsent:nil. |
|
2974 |
item notNil ifTrue:[self widthFor:item]. |
|
2975 |
]. |
|
3717 | 2976 |
]. |
2977 |
^ xSplitbars last |
|
2978 |
! |
|
2979 |
||
2980 |
xAbsoluteOfSplitbarAt:anIndex |
|
2981 |
"returns the physical x of the splitbar at an index |
|
2982 |
" |
|
2983 |
^ xSplitbars at:anIndex |
|
2984 |
! |
|
2985 |
||
3909 | 2986 |
xAbsoluteToColumnIndex:absX |
2987 |
"returns the column index for position x or 0 if not detected" |
|
2988 |
||
2989 |
|nextX| |
|
2990 |
||
2991 |
nextX := nil. |
|
2992 |
||
2993 |
"/ must walk reverse because a column could have a zero width |
|
2994 |
xSplitbars keysAndValuesReverseDo:[:index :x| |
|
2995 |
nextX notNil ifTrue:[ |
|
2996 |
x <= absX ifTrue:[ |
|
2997 |
nextX >= absX ifTrue:[^ index + 1]. |
|
2998 |
]. |
|
2999 |
]. |
|
3000 |
nextX := x. |
|
3001 |
]. |
|
3002 |
nextX notNil ifTrue:[ |
|
3003 |
nextX >= absX ifTrue:[^ 1]. |
|
3004 |
]. |
|
3005 |
^ 0 |
|
3006 |
||
3007 |
"Created: / 16-06-2010 / 16:25:33 / cg" |
|
3008 |
! |
|
3009 |
||
3717 | 3010 |
xAbsoluteToSplitbar:absX |
3909 | 3011 |
"returns the splitbar index at the position x or 0 if not detected" |
3012 |
||
3717 | 3013 |
|minX maxX| |
3014 |
||
3015 |
minX := absX - 2. |
|
3016 |
maxX := absX + 2. |
|
3017 |
||
3018 |
"/ must walk reverse because a column could have a zero width |
|
3019 |
xSplitbars keysAndValuesReverseDo:[:index :x| |
|
3909 | 3020 |
(x between:minX and:maxX) ifTrue:[^ index]. |
3717 | 3021 |
]. |
3022 |
^ 0 |
|
3909 | 3023 |
|
3024 |
"Modified: / 16-06-2010 / 16:23:12 / cg" |
|
3717 | 3025 |
! |
3026 |
||
3027 |
xVisibleOfLastSplitbar |
|
3028 |
"answer the visible x position of the last splitBar" |
|
3029 |
||
3030 |
^ self xVisibleOfSplitbarAt:(xSplitbars size). |
|
3031 |
! |
|
3032 |
||
3033 |
xVisibleOfSplitbarAt:anIndex |
|
3034 |
"returns the visible x of the splitbar at an index |
|
3035 |
" |
|
3036 |
|x| |
|
3037 |
||
3038 |
x := xSplitbars at:anIndex. |
|
3039 |
^ x - (view viewOrigin x) |
|
3040 |
! |
|
3041 |
||
4201
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3042 |
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
|
3043 |
"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
|
3044 |
^ 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
|
3045 |
|
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3046 |
"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
|
3047 |
! |
916929769f2f
Added more helper methods to query cell bounding box and position
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4199
diff
changeset
|
3048 |
|
3717 | 3049 |
xVisibleToSplitbar:visX |
3909 | 3050 |
"returns the splitbar index at the position x or 0 if not detected" |
3051 |
||
3717 | 3052 |
^ self xAbsoluteToSplitbar:(visX + view viewOrigin x). |
3909 | 3053 |
|
3054 |
"Modified: / 16-06-2010 / 16:22:56 / cg" |
|
3717 | 3055 |
! ! |
3056 |
||
3057 |
!ListModelView::TableRenderer::ColumnDescriptor class methodsFor:'instance creation'! |
|
3058 |
||
3059 |
dataSetColumnSpec:aDataSetColumnSpec |
|
3060 |
^ self new dataSetColumnSpec:aDataSetColumnSpec |
|
3061 |
! |
|
3062 |
||
3063 |
new |
|
3064 |
ClipColumnQuerySignal isNil ifTrue:[ |
|
3728 | 3065 |
ClipColumnQuerySignal := QuerySignal new. |
3717 | 3066 |
]. |
3067 |
^ self basicNew initialize |
|
3068 |
! ! |
|
3069 |
||
3070 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'accessing'! |
|
3071 |
||
3072 |
alignment |
|
3073 |
"returns the aligmnent of the contents of the underlaying cell" |
|
3074 |
||
3075 |
|alignment| |
|
3076 |
||
3077 |
alignment := dataSetColumnSpec columnAlignment. |
|
3078 |
^ alignment ? #left |
|
3079 |
! |
|
3080 |
||
3723 | 3081 |
dataSetColumnSpec |
3082 |
^ dataSetColumnSpec |
|
3083 |
! |
|
3084 |
||
3085 |
dataSetColumnSpec:aDataSetColumnSpec |
|
3086 |
||
3087 |
aDataSetColumnSpec isSequenceable ifTrue:[ |
|
3728 | 3088 |
dataSetColumnSpec := DataSetColumnSpec decodeFromLiteralArray:aDataSetColumnSpec. |
3723 | 3089 |
] ifFalse:[ |
3728 | 3090 |
dataSetColumnSpec := aDataSetColumnSpec. |
3723 | 3091 |
]. |
3092 |
! |
|
3093 |
||
3717 | 3094 |
defaultColumnWidth |
3095 |
|width| |
|
3096 |
||
3097 |
width := (dataSetColumnSpec width ? 0) max:(dataSetColumnSpec minWidth ? 0). |
|
3098 |
width > 0 ifTrue:[^ width ]. |
|
3099 |
||
3100 |
^ 70 |
|
3101 |
! |
|
3102 |
||
3103 |
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
|
3104 |
|
b5f21412bcb0
Hack to workaround new symbolic height specifier (which is made default)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4323
diff
changeset
|
3105 |
"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
|
3106 |
dataSetColumnSpec height isNumber ifFalse:[ ^ 0 ]. |
3717 | 3107 |
^ 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
|
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 |
"Modified: / 23-08-2013 / 17:59:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 3110 |
! |
3111 |
||
3112 |
showVerticalSplitbar |
|
3113 |
"answer true if the verical splitbar is shown" |
|
3114 |
||
3115 |
^ dataSetColumnSpec showColSeparator ? true. |
|
4217
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3116 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3117 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3118 |
width |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3119 |
"Return |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3120 |
- 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
|
3121 |
- 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
|
3122 |
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
|
3123 |
" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3124 |
^width |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3125 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3126 |
"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
|
3127 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3128 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3129 |
width:anInteger |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3130 |
width := anInteger. |
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 |
widthMin |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3134 |
"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
|
3135 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3136 |
^dataSetColumnSpec minWidth |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3137 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3138 |
"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
|
3139 |
! |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3140 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3141 |
widthSpec |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3142 |
"Return either |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3143 |
- 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
|
3144 |
- relative width as Float" |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3145 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3146 |
| w | |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3147 |
w := dataSetColumnSpec width. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3148 |
w isFloat ifTrue:[ ^ w ]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3149 |
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
|
3150 |
w > 0 ifFalse:[ |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3151 |
w := 70 |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3152 |
]. |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3153 |
^w |
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3154 |
|
806440cdc323
Initial support for flex-width columns for TableRenderer.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4207
diff
changeset
|
3155 |
"Created: / 07-05-2013 / 17:58:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 3156 |
! ! |
3157 |
||
3158 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'displaying'! |
|
3159 |
||
3160 |
drawRowAt:aRowNr shownSelected:isShownSelected receiver:aReceiver x:x y:y w:w h:h on:aGC |
|
3161 |
"display a column for a specific row" |
|
3162 |
||
4901 | 3163 |
|oldClippingRectangle paint savedPaint label drawSelector | |
3717 | 3164 |
|
3165 |
isShownSelected ifFalse:[ |
|
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3166 |
"/ 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
|
3167 |
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
|
3168 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3169 |
paint notNil ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3170 |
savedPaint := aGC paint. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3171 |
aGC paint:paint. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3172 |
"/ 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
|
3173 |
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
|
3174 |
]. |
3717 | 3175 |
]. |
3176 |
w < 5 ifTrue:[ ^ self ]. "/ makes no sense to draw the label |
|
3177 |
||
3178 |
label := self extractColumnFrom:aReceiver rowNr:aRowNr on:aGC. |
|
3179 |
label isEmptyOrNil ifTrue:[^ self]. |
|
3180 |
||
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3181 |
(drawSelector := dataSetColumnSpec drawSelector) notNil ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3182 |
"/ Set clip rect to make sure nobody can draw outside the cell |
4901 | 3183 |
oldClippingRectangle := aGC clippingRectangleOrNil. |
4199
9e655a8d339f
Workaround stc bug, sigh
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4198
diff
changeset
|
3184 |
aGC clippingRectangle:(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
|
3185 |
drawSelector numArgs == 5 ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3186 |
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
|
3187 |
] ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3188 |
drawSelector numArgs == 6 ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3189 |
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
|
3190 |
] ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3191 |
self error: 'Invalid draw selector' |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3192 |
] |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3193 |
]. |
4901 | 3194 |
aGC clippingRectangle:oldClippingRectangle. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3195 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3196 |
|
4199
9e655a8d339f
Workaround stc bug, sigh
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4198
diff
changeset
|
3197 |
drawSelector notNil ifTrue:[ ^ self ]. |
9e655a8d339f
Workaround stc bug, sigh
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4198
diff
changeset
|
3198 |
|
3717 | 3199 |
ClipColumnQuerySignal handle:[:ex| |
4901 | 3200 |
oldClippingRectangle isNil ifTrue:[ |
3201 |
oldClippingRectangle := aGC clippingRectangleOrNil. |
|
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3202 |
aGC clippingRectangle:(Rectangle left:x top:y width:w height:h). |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3203 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3204 |
ex proceedWith:true. |
3717 | 3205 |
] do:[ |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3206 |
isShownSelected ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3207 |
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
|
3208 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3209 |
paint notNil ifTrue:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3210 |
aGC paint:paint. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3211 |
] ifFalse:[ |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3212 |
savedPaint notNil ifTrue:[ aGC paint:savedPaint ]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3213 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3214 |
]. |
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3215 |
self drawObject:label x:x y:y w:w h:h on:aGC. |
3717 | 3216 |
]. |
4901 | 3217 |
oldClippingRectangle notNil ifTrue:[ |
3218 |
aGC clippingRectangle:oldClippingRectangle. |
|
3717 | 3219 |
]. |
4197
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3220 |
|
a3688c9c86fe
Added support for custom cell rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4168
diff
changeset
|
3221 |
"Modified: / 17-04-2013 / 13:05:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
3717 | 3222 |
! ! |
3223 |
||
3224 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'extract values'! |
|
3225 |
||
3226 |
extractBackgroundColorFrom:aReceiver rowNr:aRowNr on:aView |
|
3227 |
|color selector| |
|
3228 |
||
3229 |
aReceiver notNil ifTrue:[ |
|
3728 | 3230 |
selector := dataSetColumnSpec backgroundSelector. |
3231 |
||
3232 |
selector notNil ifTrue:[ |
|
3233 |
color := aReceiver perform:selector withOptionalArgument:columnNumber and:aRowNr and:aView. |
|
3234 |
color notNil ifTrue:[ ^ color ]. |
|
3235 |
]. |
|
3717 | 3236 |
]. |
3237 |
^ dataSetColumnSpec backgroundColor. |
|
3238 |
! |
|
3239 |
||
3240 |
extractColumnFrom:aReceiver rowNr:aRowNr on:aView |
|
3241 |
|selector| |
|
3242 |
||
3243 |
aReceiver notNil ifTrue:[ |
|
4205 | 3244 |
selector := dataSetColumnSpec printSelector ? dataSetColumnSpec readSelector. |
3245 |
||
3246 |
selector notNil ifTrue:[ |
|
3247 |
^ aReceiver perform:selector withOptionalArgument:columnNumber and:aRowNr and:aView |
|
3248 |
]. |
|
3717 | 3249 |
]. |
3250 |
^ nil |
|
4205 | 3251 |
|
3252 |
"Modified: / 22-04-2013 / 14:04:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3717 | 3253 |
! |
3254 |
||
3255 |
extractForegroundColorFrom:aReceiver rowNr:aRowNr on:aView |
|
3256 |
|color selector| |
|
3257 |
||
3258 |
aReceiver notNil ifTrue:[ |
|
3728 | 3259 |
selector := dataSetColumnSpec foregroundSelector. |
3260 |
||
3261 |
selector notNil ifTrue:[ |
|
3262 |
color := aReceiver perform:selector withOptionalArgument:columnNumber and:aRowNr and:aView. |
|
3263 |
color notNil ifTrue:[ ^ color ]. |
|
3264 |
]. |
|
3717 | 3265 |
]. |
3266 |
^ dataSetColumnSpec foregroundColor. |
|
3267 |
! ! |
|
3268 |
||
3269 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'instance creation'! |
|
3270 |
||
3271 |
columnNumber:aNumber |
|
3272 |
columnNumber := aNumber. |
|
3273 |
! ! |
|
3274 |
||
3275 |
!ListModelView::TableRenderer::ColumnDescriptor methodsFor:'private displaying'! |
|
3276 |
||
3277 |
alignAndDisplay:anObject x:x y:y w:w on:aGC |
|
3278 |
"display an object on aGC; care for alignment" |
|
3279 |
||
3280 |
|x0 width align| |
|
3281 |
||
3282 |
x0 := x. |
|
3283 |
align := self alignment. |
|
3284 |
||
3285 |
align ~~ #left ifTrue:[ |
|
3728 | 3286 |
width := anObject widthOn:aGC. |
3287 |
||
3288 |
width < w ifTrue:[ |
|
3289 |
align == #right ifTrue:[ |
|
3290 |
x0 := x0 + w - width |
|
3291 |
] ifFalse:[ |
|
3292 |
x0 := x0 + ((w - width) // 2) |
|
3293 |
]. |
|
3294 |
]. |
|
3717 | 3295 |
]. |
3296 |
anObject displayOn:aGC x:x0 y:y. |
|
3297 |
! |
|
3298 |
||
3299 |
displayImage:anImage x:x y:y w:w h:h on:aGC |
|
3300 |
"display an image on aGC; answer the height used...." |
|
3301 |
||
3302 |
|height| |
|
3303 |
||
3304 |
height := anImage heightOn:aGC. |
|
3305 |
||
3306 |
height > h ifTrue:[ |
|
3728 | 3307 |
(self queryForClipColumnWithAvailableHeight:h) ifFalse:[ |
3308 |
^ height |
|
3309 |
]. |
|
3717 | 3310 |
]. |
3311 |
self alignAndDisplay:anImage x:x y:y w:w on:aGC. |
|
3312 |
^ height |
|
3313 |
! |
|
3314 |
||
3315 |
displayLabelAndIcon:aLabelAndIcon x:x y:y w:w h:h on:aGC |
|
3316 |
"display an image on aGC; answer the height used...." |
|
3317 |
||
3318 |
|height| |
|
3319 |
||
3320 |
height := aLabelAndIcon heightOn:aGC. |
|
3321 |
||
3322 |
height > h ifTrue:[ |
|
3728 | 3323 |
(self queryForClipColumnWithAvailableHeight:h) ifFalse:[ |
3324 |
^ height |
|
3325 |
]. |
|
3717 | 3326 |
]. |
3327 |
||
3328 |
self alignAndDisplay:aLabelAndIcon x:x y:(y + aGC font ascent) w:w on:aGC. |
|
3329 |
^ height |
|
3330 |
! |
|
3331 |
||
3332 |
displayString:aString x:x y:y w:w h:h on:aGC |
|
3333 |
"display a string on aGC; answer the height used...." |
|
3334 |
||
3335 |
|shortWidth font shortedLabel fontHeight| |
|
3336 |
||
3337 |
font := aGC font. |
|
3719 | 3338 |
fontHeight := font height. |
3717 | 3339 |
|
3340 |
aString isEmptyOrNil ifTrue:[ ^ fontHeight ]. |
|
3341 |
||
3342 |
(self queryForClipColumnWithAvailableHeight:h) ifFalse:[ |
|
3728 | 3343 |
^ fontHeight |
3717 | 3344 |
]. |
3719 | 3345 |
dataSetColumnSpec longStringCompression ifTrue:[ |
3728 | 3346 |
shortWidth := font widthOf:aString. |
3347 |
||
3348 |
shortWidth <= w ifTrue:[ |
|
3349 |
shortedLabel := aString. |
|
3350 |
] ifFalse:[ |
|
3351 |
|dottedString dottedWidth index| |
|
3352 |
||
3353 |
dottedString := '...'. |
|
3354 |
dottedWidth := font widthOf:dottedString. |
|
3355 |
||
3356 |
w < dottedWidth ifTrue:[ ^ fontHeight ]. "/ give up |
|
3357 |
||
3358 |
index := aString size // 2. |
|
3359 |
||
3360 |
[ index := index - 1. |
|
3361 |
||
3362 |
index > 0 ifTrue:[ |
|
3363 |
shortedLabel := (aString copyFirst:index), '...', (aString copyLast:index). |
|
3364 |
shortWidth := font widthOf:shortedLabel. |
|
3365 |
] ifFalse:[ |
|
3366 |
shortedLabel := dottedString. |
|
3367 |
shortWidth := dottedWidth. |
|
3368 |
]. |
|
3369 |
shortWidth > w |
|
3370 |
] whileTrue. |
|
3371 |
]. |
|
3717 | 3372 |
] ifFalse:[ |
3728 | 3373 |
shortedLabel := aString |
3717 | 3374 |
]. |
3375 |
||
3376 |
shortedLabel notNil ifTrue:[ |
|
3728 | 3377 |
self alignAndDisplay:shortedLabel x:x y:(y + aGC font ascent) w:w on:aGC. |
3717 | 3378 |
]. |
3379 |
^ fontHeight. |
|
3380 |
! |
|
3381 |
||
3382 |
drawObject:anObject x:x y:y w:w h:h on:aGC |
|
3383 |
"display any object (sequence of objects) on aGC; answer the height used...." |
|
3384 |
||
3385 |
|totalHeight usedHeight| |
|
3386 |
||
3387 |
h < 4 ifTrue:[ ^ h ]. |
|
3388 |
||
3389 |
anObject isEmptyOrNil ifTrue:[ ^ 2 ]. "/ nothing to draw; add 2 pixels |
|
3390 |
||
3391 |
anObject isImage ifTrue:[ |
|
3728 | 3392 |
^ self displayImage:anObject x:x y:y w:w h:h on:aGC. |
3717 | 3393 |
]. |
3394 |
anObject isString ifTrue:[ |
|
3728 | 3395 |
^ self displayString:anObject x:x y:y w:w h:h on:aGC. |
3396 |
]. |
|
3717 | 3397 |
anObject isSequenceable ifFalse:[ |
3728 | 3398 |
"/ not yet handled.... |
3399 |
anObject class == LabelAndIcon ifTrue:[ |
|
3400 |
^ self displayLabelAndIcon:anObject x:x y:y w:w h:h on:aGC |
|
3401 |
]. |
|
3402 |
||
3403 |
^ self displayString:(anObject printString) x:x y:y w:w h:h on:aGC |
|
3717 | 3404 |
]. |
3405 |
||
3406 |
totalHeight := 0. |
|
3407 |
||
3408 |
anObject do:[:aSubObj| |
|
3728 | 3409 |
totalHeight < h ifTrue:[ |
3410 |
usedHeight := self |
|
3411 |
drawObject:aSubObj |
|
3412 |
x:x |
|
3413 |
y:(y + totalHeight) |
|
3414 |
w:w |
|
3415 |
h:(h - totalHeight) |
|
3416 |
on:aGC. |
|
3417 |
||
3418 |
totalHeight := totalHeight + usedHeight. |
|
3419 |
]. |
|
3717 | 3420 |
]. |
3421 |
^ (h - totalHeight) |
|
3422 |
! |
|
3423 |
||
3424 |
queryForClipColumnWithAvailableHeight:anAvailableHeight |
|
3425 |
||
3426 |
anAvailableHeight > 8 ifTrue:[ |
|
3728 | 3427 |
^ (ClipColumnQuerySignal query) == true |
3717 | 3428 |
]. |
3429 |
^ false. |
|
3430 |
! ! |
|
3431 |
||
1390 | 3432 |
!ListModelView class methodsFor:'documentation'! |
3433 |
||
3434 |
version |
|
4858 | 3435 |
^ '$Header$' |
3891 | 3436 |
! |
3437 |
||
3438 |
version_CVS |
|
4858 | 3439 |
^ '$Header$' |
1390 | 3440 |
! ! |
2244
c9a195d28e72
change #redrawLineAt: to #invalidateLineAt: (because is a invalidate)
ca
parents:
2188
diff
changeset
|
3441 |
|
4168 | 3442 |
|
1390 | 3443 |
ListModelView initialize! |