equal
deleted
inserted
replaced
273 setChildPositions |
273 setChildPositions |
274 "(re)compute position of every child" |
274 "(re)compute position of every child" |
275 |
275 |
276 |xpos ypos space sumOfHeights numChilds l hEach hInside hL vL |
276 |xpos ypos space sumOfHeights numChilds l hEach hInside hL vL |
277 maxWidth maxHeight resizeToMaxV resizeToMaxH m2 subViews restHeight |
277 maxWidth maxHeight resizeToMaxV resizeToMaxH m2 subViews restHeight |
278 rowsPerCol maxWidthPerCol col numCols cX cY| |
278 rowsPerCol maxWidthPerCol col numCols cX cY bw| |
279 |
279 |
280 subViews := self subViewsToConsider. |
280 subViews := self subViewsToConsider. |
281 subViews size == 0 ifTrue:[^ self]. |
281 subViews size == 0 ifTrue:[^ self]. |
282 |
282 |
283 "/ self extentChangedFlag ifTrue:[ |
283 "/ self extentChangedFlag ifTrue:[ |
288 |
288 |
289 space := verticalSpace. |
289 space := verticalSpace. |
290 numChilds := subViews size. |
290 numChilds := subViews size. |
291 numCols := columnWidths size max:1. |
291 numCols := columnWidths size max:1. |
292 |
292 |
|
293 bw := self borderWidth. |
293 m2 := margin * 2. |
294 m2 := margin * 2. |
294 hInside := height - m2 + (borderWidth*2) - subViews last borderWidth. |
295 hInside := height - m2 + (bw*2) - subViews last borderWidth. |
295 |
296 |
296 hL := hLayout. |
297 hL := hLayout. |
297 vL := vLayout. |
298 vL := vLayout. |
298 |
299 |
299 rowsPerCol := Array new:numCols withAll:0. |
300 rowsPerCol := Array new:numCols withAll:0. |
361 " |
362 " |
362 adjust childs extents and set origins. |
363 adjust childs extents and set origins. |
363 Be careful to avoid accumulation of rounding errors |
364 Be careful to avoid accumulation of rounding errors |
364 " |
365 " |
365 hEach := (hInside - ((numChilds + 1) * space)) / numChilds. |
366 hEach := (hInside - ((numChilds + 1) * space)) / numChilds. |
366 ypos := space + margin - borderWidth. |
367 ypos := space + margin - bw. |
367 ] ifFalse:[ |
368 ] ifFalse:[ |
368 vL == #fit ifTrue:[ |
369 vL == #fit ifTrue:[ |
369 " |
370 " |
370 adjust childs extents and set origins. |
371 adjust childs extents and set origins. |
371 Be careful to avoid accumulation of rounding errors |
372 Be careful to avoid accumulation of rounding errors |
372 " |
373 " |
373 hEach := (hInside - ((numChilds - 1) * space)) / numChilds. |
374 hEach := (hInside - ((numChilds - 1) * space)) / numChilds. |
374 ypos := margin - borderWidth. |
375 ypos := margin - bw. |
375 ] ifFalse:[ |
376 ] ifFalse:[ |
376 l := vL. |
377 l := vL. |
377 |
378 |
378 " |
379 " |
379 compute net height needed |
380 compute net height needed |
420 ]. |
421 ]. |
421 ((l == #bottom) or:[l == #bottomSpace |
422 ((l == #bottom) or:[l == #bottomSpace |
422 or:[l == #bottomFit or:[l == #bottomSpaceFit]]]) ifTrue:[ |
423 or:[l == #bottomFit or:[l == #bottomSpaceFit]]]) ifTrue:[ |
423 ypos := restHeight - (space * (numChilds - 1)). |
424 ypos := restHeight - (space * (numChilds - 1)). |
424 "/ |
425 "/ |
425 "/ borderWidth == 0 ifTrue:[ |
426 "/ bw == 0 ifTrue:[ |
426 "/ ypos := ypos + space |
427 "/ ypos := ypos + space |
427 "/ ]. |
428 "/ ]. |
428 "/ |
429 "/ |
429 (l == #bottomSpace |
430 (l == #bottomSpace |
430 or:[l == #bottomSpaceFit]) ifTrue:[ |
431 or:[l == #bottomSpaceFit]) ifTrue:[ |
512 resizeToMaxH ifTrue:[ |
513 resizeToMaxH ifTrue:[ |
513 child width:(wChild := maxWidth - (bwChild * 2)). |
514 child width:(wChild := maxWidth - (bwChild * 2)). |
514 ]. |
515 ]. |
515 |
516 |
516 hL == #left ifTrue:[ |
517 hL == #left ifTrue:[ |
517 xpos := 0 - borderWidth + margin. |
518 xpos := 0 - bw + margin. |
518 ] ifFalse:[ |
519 ] ifFalse:[ |
519 hL == #leftSpace ifTrue:[ |
520 hL == #leftSpace ifTrue:[ |
520 xpos := horizontalSpace + margin |
521 xpos := horizontalSpace + margin |
521 ] ifFalse:[ |
522 ] ifFalse:[ |
522 hL == #right ifTrue:[ |
523 hL == #right ifTrue:[ |
529 xpos := horizontalSpace + margin. |
530 xpos := horizontalSpace + margin. |
530 newWChild := width - m2 - ((horizontalSpace + bwChild) * 2) |
531 newWChild := width - m2 - ((horizontalSpace + bwChild) * 2) |
531 ] ifFalse:[ |
532 ] ifFalse:[ |
532 hL == #fit ifTrue:[ |
533 hL == #fit ifTrue:[ |
533 newWChild := width "- (bwChild * 2)". |
534 newWChild := width "- (bwChild * 2)". |
534 borderWidth == 0 ifTrue:[ |
535 bw == 0 ifTrue:[ |
535 newWChild := newWChild - (bwChild * 2) |
536 newWChild := newWChild - (bwChild * 2) |
536 ]. |
537 ]. |
537 true "child level == 0" ifTrue:[ |
538 true "child level == 0" ifTrue:[ |
538 xpos := margin - borderWidth. |
539 xpos := margin - bw. |
539 newWChild := newWChild - m2 |
540 newWChild := newWChild - m2 |
540 ] ifFalse:[ |
541 ] ifFalse:[ |
541 xpos := 0 - borderWidth. |
542 xpos := 0 - bw. |
542 ]. |
543 ]. |
543 ] ifFalse:[ |
544 ] ifFalse:[ |
544 "centered" |
545 "centered" |
545 xpos := margin + ((width - m2 - wChild) // 2). |
546 xpos := margin + ((width - m2 - wChild) // 2). |
546 ] |
547 ] |
579 child corner:x2 @ y |
580 child corner:x2 @ y |
580 ]. |
581 ]. |
581 ]. |
582 ]. |
582 index == 1 ifTrue:[ |
583 index == 1 ifTrue:[ |
583 (vL == #bottomFit or:[vL == #bottomSpaceFit]) ifTrue:[ |
584 (vL == #bottomFit or:[vL == #bottomSpaceFit]) ifTrue:[ |
584 ypos := margin + 0 + (child borderWidth * 2) - borderWidth. |
585 ypos := margin + 0 + (child borderWidth * 2) - bw. |
585 vL == #bottomSpaceFit ifTrue:[ |
586 vL == #bottomSpaceFit ifTrue:[ |
586 ypos := ypos + space |
587 ypos := ypos + space |
587 ]. |
588 ]. |
588 advance := restHeight. |
589 advance := restHeight. |
589 child origin:((child origin x) @ ypos) |
590 child origin:((child origin x) @ ypos) |
640 rowsPerCol at:col put:(rowsPerCol at:col)+1. |
641 rowsPerCol at:col put:(rowsPerCol at:col)+1. |
641 col := col + 1. |
642 col := col + 1. |
642 col > numCols ifTrue:[ col := 1 ]. |
643 col > numCols ifTrue:[ col := 1 ]. |
643 ]. |
644 ]. |
644 |
645 |
645 borderWidth ~~ 0 ifTrue:[ |
646 self borderWidth ~~ 0 ifTrue:[ |
646 maxWidth := maxWidth + (horizontalSpace * 2). |
647 maxWidth := maxWidth + (horizontalSpace * 2). |
647 ]. |
648 ]. |
648 |
649 |
649 "/ sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace). |
650 "/ sumOfHeights := sumOfHeights + ((subViews size - 1) * verticalSpace). |
650 "/ ((vLayout == #topSpace) or:[vLayout == #bottomSpace]) ifTrue:[ |
651 "/ ((vLayout == #topSpace) or:[vLayout == #bottomSpace]) ifTrue:[ |
673 ! ! |
674 ! ! |
674 |
675 |
675 !MultiColumnPanelView class methodsFor:'documentation'! |
676 !MultiColumnPanelView class methodsFor:'documentation'! |
676 |
677 |
677 version |
678 version |
678 ^ '$Header: /cvs/stx/stx/libwidg/MultiColumnPanelView.st,v 1.2 2008-10-26 20:11:53 stefan Exp $' |
679 ^ '$Header: /cvs/stx/stx/libwidg/MultiColumnPanelView.st,v 1.3 2009-10-23 15:22:19 cg Exp $' |
|
680 ! |
|
681 |
|
682 version_CVS |
|
683 ^ '$Header: /cvs/stx/stx/libwidg/MultiColumnPanelView.st,v 1.3 2009-10-23 15:22:19 cg Exp $' |
679 ! ! |
684 ! ! |