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