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