#BUGFIX by ca
authorca
Thu, 02 May 2019 12:26:09 +0200
changeset 6045 c1e2a95ac169
parent 6044 e7fd53f408b8
child 6046 076bfb11d13d
#BUGFIX by ca class: TabView added: #recomputeListHorizontal comment/format in: #_ok_recomputeListHorizontal class: TabView class
TabView.st
--- a/TabView.st	Sat Apr 27 09:50:57 2019 +0200
+++ b/TabView.st	Thu May 02 12:26:09 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1997 by eXept Software AG
 	      All Rights Reserved
@@ -11,6 +13,8 @@
 "
 "{ Package: 'stx:libwidg2' }"
 
+"{ NameSpace: Smalltalk }"
+
 NoteBookView subclass:#TabView
 	instanceVariableNames:''
 	classVariableNames:''
@@ -132,6 +136,114 @@
 "
 ! !
 
+!TabView methodsFor:'accessing'!
+
+recomputeListHorizontal
+    "compute layouts for all tabs"
+
+    | borderLevel xLeft xRight yTop tabWidth tabHeight delta tabLvlAbs minLeft maxRight leftMargin rightMargin |
+
+    maxRight := self width  // list size.
+    maxRight < 7 ifTrue:[
+        selectionInsetX := 0.
+        maxRight > 5 ifTrue:[ selectionInsetX := 1 ].
+    ] ifFalse:[
+        selectionInsetX := 2.
+        maxRight > 8 ifTrue:[ selectionInsetX := 3 ].
+    ].
+    tabLabelInset x: 0.
+
+    tabLvlAbs   := tabLevel abs.
+    borderLevel := tabLvlAbs * 2.
+    tabHeight   := 0.
+    leftMargin  := self tabLeftMargin.
+    rightMargin := self tabRightMargin.
+    minLeft     := leftMargin + selectionInsetX.
+    maxRight    := self width - rightMargin - selectionInsetX.
+    xLeft       := minLeft.
+
+    addTabAction notNil
+        ifTrue:[ maxRight := maxRight - self horizontalMarginForAddTabButton ].
+
+    list do:[:aTab| |tabExtent|
+        tabExtent := self preferredExtentForTab:aTab.
+        tabWidth  := tabExtent x + borderLevel.
+        tabHeight := tabExtent y max:tabHeight.
+        xRight    := xLeft + tabWidth.
+
+        aTab destroyTabButtonShown ifTrue:[
+            xRight := xRight + self destroyButtonUsedWidth
+        ].
+
+        aTab lineNr: 1.
+        aTab unselectedLayout:(Rectangle left:xLeft top:0 width:tabWidth height:tabHeight).
+        xLeft := xRight.
+    ].
+    tabHeight := tabHeight + tabLvlAbs.
+    yTop      := selectionInsetY + tabTopMargin.
+    delta     := tabHeight.
+
+    direction == #bottom ifTrue:[
+        yTop  := self height - tabHeight - yTop.
+        delta := tabHeight negated.
+    ].
+
+    list reverseDo:[:aTab|
+        aTab unselectedLayout setTop:yTop.
+        aTab unselectedLayout height:tabHeight.
+    ].
+
+    tabModus ifTrue:[
+        |firstTabLayout|
+
+        firstTabLayout := list first unselectedLayout.
+        delta  := direction == #top 
+                        ifTrue:[self height - firstTabLayout bottom]
+                        ifFalse:[firstTabLayout top negated].
+
+        list do:[:aTab | |l|
+                l := aTab unselectedLayout.
+                l setTop:(l top + delta).
+        ].
+    ].
+
+    list isEmpty ifTrue:[ ^ self ].
+    
+    delta := maxRight - list last unselectedLayout right.
+    [ delta < 0 ] whileTrue:[ |tab wdt|
+        tab := nil.
+        wdt := 2.
+
+        list do:[: each |
+            each unselectedLayout width > wdt ifTrue:[
+                tab := each.
+                wdt := each unselectedLayout width.
+            ].
+        ].
+        tab isNil
+             ifTrue:[ delta := 0 ]
+            ifFalse:[ delta := delta + 1. tab unselectedLayout width: (tab unselectedLayout width - 1) ].
+    ].
+
+    [ delta > 0 ] whileTrue:[ |tab wdt|
+        tab := list first.
+        wdt := tab unselectedLayout width - tab extent x.
+
+        list from:2 to: list size do:[: each | |new|
+            new :=  each unselectedLayout width - each extent x.
+            wdt > new ifTrue:[ wdt := new. tab := each. ].
+        ].
+        tab unselectedLayout width: (tab unselectedLayout width + 1).
+        delta := delta - 1.
+    ].
+
+    2 to: list size do:[: i |
+        (list at: i) unselectedLayout setLeft: ((list at: i -1) unselectedLayout right).
+    ].
+
+    list do:[:eachTab | eachTab layout:eachTab unselectedLayout; selectedLayout:nil ].
+! !
+
 !TabView methodsFor:'initialization'!
 
 initStyle
@@ -147,9 +259,10 @@
 !TabView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TabView.st,v 1.48 2010-05-11 11:43:14 ca Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/TabView.st,v 1.48 2010-05-11 11:43:14 ca Exp $'
+    ^ '$Header$'
 ! !
+