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