207 super list:list keepSelection:keepSelection |
208 super list:list keepSelection:keepSelection |
208 ! ! |
209 ! ! |
209 |
210 |
210 !SelectionInTreeView methodsFor:'accessing-behavior'! |
211 !SelectionInTreeView methodsFor:'accessing-behavior'! |
211 |
212 |
|
213 doubleClickSelectionBlock |
|
214 "get the conditionBlock; this block is evaluated before a doubleClick action |
|
215 on a node containg children will be performed. In case of returning false, the |
|
216 doubleClick will not be handled. |
|
217 " |
|
218 ^ doubleClickSelectionBlock |
|
219 |
|
220 |
|
221 ! |
|
222 |
|
223 doubleClickSelectionBlock:aBlock |
|
224 "set the conditionBlock; this block is evaluated before a doubleClick action |
|
225 on a node containg children will be performed. In case of returning false, the |
|
226 doubleClick will not be handled. |
|
227 " |
|
228 doubleClickSelectionBlock := aBlock |
|
229 |
|
230 |
|
231 ! |
|
232 |
212 showLines |
233 showLines |
213 "returns true if lines are shown |
234 "returns true if lines are shown |
214 " |
235 " |
215 ^ showLines |
236 ^ showLines |
216 ! |
237 ! |
354 fetchDeviceResources |
375 fetchDeviceResources |
355 "initialize heavily used device resources - to avoid rendering |
376 "initialize heavily used device resources - to avoid rendering |
356 images again and again later" |
377 images again and again later" |
357 |
378 |
358 super fetchDeviceResources. |
379 super fetchDeviceResources. |
359 |
380 self refetchDeviceResources |
360 figuresInset := self class figuresInset. |
381 ! |
|
382 |
|
383 fetchImageResources |
|
384 "initialize heavily used device resources - to avoid rendering |
|
385 images again and again later; returns maximum extent of the images used. |
|
386 Could be redefined by subclass |
|
387 " |
|
388 |y x t| |
|
389 |
361 imageOpened := (self class imageOpened) onDevice:device. |
390 imageOpened := (self class imageOpened) onDevice:device. |
362 imageClosed := (self class imageClosed) onDevice:device. |
391 imageClosed := (self class imageClosed) onDevice:device. |
363 imageItem := (self class imageItem) onDevice:device. |
392 imageItem := (self class imageItem) onDevice:device. |
364 ! |
|
365 |
|
366 getFontParameters |
|
367 "get some info of the used font and figures. They are cached since we use them |
|
368 often .. |
|
369 " |
|
370 |extent| |
|
371 |
|
372 super getFontParameters. |
|
373 |
|
374 imageClosed isNil ifTrue:[ |
|
375 self fetchDeviceResources |
|
376 ]. |
|
377 extent := self getMaxFiguresExtent. |
|
378 |
|
379 extent y > fontHeight ifTrue:[ |
|
380 fontHeight := extent y |
|
381 ]. |
|
382 figuresWidth := extent x. |
|
383 leftIndent := figuresInset + figuresWidth. |
|
384 figuresWidthDiv2 := figuresWidth // 2. |
|
385 ! |
|
386 |
|
387 getMaxFiguresExtent |
|
388 "returns maximum extent of the figures used |
|
389 " |
|
390 |y x t| |
|
391 |
393 |
392 y := imageClosed heightOn:self. |
394 y := imageClosed heightOn:self. |
393 x := imageClosed widthOn:self. |
395 x := imageClosed widthOn:self. |
394 |
396 |
395 (t := imageOpened heightOn:self) > y ifTrue:[y := t]. |
397 (t := imageOpened heightOn:self) > y ifTrue:[y := t]. |
396 (t := imageOpened widthOn:self) > x ifTrue:[x := t]. |
398 (t := imageOpened widthOn:self) > x ifTrue:[x := t]. |
397 (t := imageItem heightOn:self) > y ifTrue:[y := t]. |
399 (t := imageItem heightOn:self) > y ifTrue:[y := t]. |
398 (t := imageItem widthOn:self) > x ifTrue:[x := t]. |
400 (t := imageItem widthOn:self) > x ifTrue:[x := t]. |
399 |
401 |
400 ^ x @ y |
402 ^ x @ y |
|
403 |
401 ! |
404 ! |
402 |
405 |
403 initialize |
406 initialize |
404 "setup instance attributes |
407 "setup instance attributes |
405 " |
408 " |
406 super initialize. |
409 super initialize. |
407 showLines := true. |
410 showLines := true. |
408 dblClickEvt := false. |
411 dblClickEvt := false. |
|
412 figuresWidth := 18. "/ default: will change during startup |
|
413 figuresInset := 2. "/ default: will change during startup |
|
414 leftIndent := figuresWidth + figuresInset. "/ default: will change during startup |
|
415 figuresWidthDiv2 := figuresWidth // 2. "/ default: will change during startup |
|
416 ! |
|
417 |
|
418 refetchDeviceResources |
|
419 "reinitialize heavily used device resources - to avoid rendering |
|
420 images again and again later |
|
421 " |
|
422 |extent| |
|
423 |
|
424 figuresInset := self class figuresInset. |
|
425 extent := self fetchImageResources. |
|
426 |
|
427 extent y > fontHeight ifTrue:[ |
|
428 fontHeight := extent y |
|
429 ]. |
|
430 figuresWidth := extent x. |
|
431 leftIndent := figuresInset + figuresWidth. |
|
432 figuresWidthDiv2 := figuresWidth // 2. |
409 |
433 |
410 ! ! |
434 ! ! |
411 |
435 |
412 !SelectionInTreeView methodsFor:'private'! |
436 !SelectionInTreeView methodsFor:'private'! |
413 |
437 |
556 |
580 |
557 (node := self selectedNode) notNil ifTrue:[ |
581 (node := self selectedNode) notNil ifTrue:[ |
558 node hasChildren ifTrue:[ |
582 node hasChildren ifTrue:[ |
559 "/ node is a children container |
583 "/ node is a children container |
560 |
584 |
|
585 doubleClickSelectionBlock notNil ifTrue:[ |
|
586 (doubleClickSelectionBlock value:(self selectedIndex)) ifFalse:[ |
|
587 ^ self |
|
588 ] |
|
589 ]. |
561 node numberOfChildren == 0 ifTrue:[ |
590 node numberOfChildren == 0 ifTrue:[ |
562 "/ but without any children, thus redraw |
591 "/ but without any children, thus redraw |
563 "/ only selected line; figure may changed |
592 "/ only selected line; figure may changed |
564 node isExpandable ifTrue:[node expand] |
593 node isExpandable ifTrue:[node expand] |
565 ifFalse:[node collapse]. |
594 ifFalse:[node collapse]. |