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