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