TabView.st
changeset 372 80d087722bc6
parent 371 02b233499001
child 373 f24a4946fce6
--- a/TabView.st	Thu Apr 24 08:11:05 1997 +0200
+++ b/TabView.st	Sat Apr 26 07:40:11 1997 +0200
@@ -644,7 +644,7 @@
 redrawRawAt:aRawNr
     "redraw raw at a number; all contained tabs are drawn unselected
     "
-    list do:[:aTab|aTab lineNr == aRawNr ifTrue:[aTab redraw:false]]
+    list reverseDo:[:aTab|aTab lineNr == aRawNr ifTrue:[aTab redraw:false]].
 !
 
 redrawSelection
@@ -707,12 +707,7 @@
     "a button is pressed; find tab under point and set the selection
     "
     list notNil ifTrue:[
-        list keysAndValuesDo:[:aKey :aTab|
-            (aTab containsPoint:(x@y)) ifTrue:[
-                ^ self selection:aKey
-            ]
-        ].
-        self selection:nil
+        self selection:(list findFirst:[:aTab|aTab containsPoint:(x@y)])
     ]
 !
 
@@ -722,14 +717,14 @@
     |size newSel|
 
     (size := list size) ~~ 0 ifTrue:[
-        (aKey == #CursorLeft or:[aKey == #CursorUp]) ifTrue:[
+        (aKey == #CursorRight or:[aKey == #CursorDown]) ifTrue:[
             (selection isNil or:[selection == size]) ifTrue:[
                 newSel := 1
             ] ifFalse:[
                 newSel := (selection + 1)
             ]
         ] ifFalse:[
-            (aKey == #CursorRight or:[aKey == #CursorDown]) ifTrue:[
+            (aKey == #CursorLeft or:[aKey == #CursorUp]) ifTrue:[
                 (selection isNil or:[selection == 1]) ifTrue:[
                     newSel := size
                 ] ifFalse:[
@@ -785,8 +780,8 @@
     "
     |tabB tabA ancA ancB hrz|
 
-    tabA := list at:(list findLast:[:aTab|aTab lineNr == aRawA]).
-    tabB := list at:(list findLast:[:aTab|aTab lineNr == aRawB]).
+    tabA := list at:(list findFirst:[:aTab|aTab lineNr == aRawA]).
+    tabB := list at:(list findFirst:[:aTab|aTab lineNr == aRawB]).
     hrz  := (self isHorizontalDirection).
 
     hrz ifTrue:[
@@ -831,7 +826,7 @@
 
     last  := list  findLast:[:aTab| aTab lineNr == aRawNr ].
     first := list findFirst:[:aTab| aTab lineNr == aRawNr ].
-    tab   := list at:first.
+    tab   := list at:last.
     size  := last - first + 1.
     org   := 0.
 
@@ -840,13 +835,13 @@
         ext := (max - ((tab anchor x) + (tab extent x))) // size.
 
         ext > 1 ifTrue:[
-            last to:first by:-1 do:[:i|
+            first to:last do:[:i|
                 tab := list at:i.
                 tab extent x:((tab extent x) + ext).
                 tab anchor x:((tab anchor x) + org).
                 org := org + ext.
             ].
-            tab := list at:first.
+            tab := list at:last.
         ].
         tab extent x:(max - tab anchor x).
     ] ifFalse:[
@@ -854,13 +849,13 @@
         ext := (max - ((tab anchor y) + (tab extent y))) // size.
 
         ext > 1 ifTrue:[
-            last to:first by:-1 do:[:i|
+            first to:last do:[:i|
                 tab := list at:i.
                 tab extent y:((tab extent y) + ext).
                 tab anchor y:((tab anchor y) + org).
                 org := org + ext.
             ].
-            tab := list at:first.
+            tab := list at:last.
         ].
         tab extent y:(max - tab anchor y).
     ]
@@ -881,7 +876,7 @@
             x     := 0.
             y     := maxY.
 
-            list reverseDo:[:aTab||eX n|
+            list do:[:aTab||eX n|
                 eX := aTab preferredExtentX.
                 n  := eX + x - ovl.
 
@@ -900,7 +895,7 @@
             x     := maxY.
             y     := 0.
 
-            list reverseDo:[:aTab||eY n|
+            list do:[:aTab||eY n|
                 eY := aTab preferredExtentX.
                 n  := eY + y - ovl.
 
@@ -933,7 +928,7 @@
     pos   := 0.
     hrz   := (self isHorizontalDirection).
 
-    last to:first by:-1 do:[:i|
+    first to:last do:[:i|
         tab := list at:i.
         anchor := tab anchor.
         extent := tab extent.
@@ -1014,7 +1009,8 @@
     ] ifFalse:[
         index := anIndexOrNil
     ].
-        
+    index == 0 ifTrue:[index := nil].
+
     selection == index ifTrue:[
         ^ self
     ].
@@ -1042,5 +1038,5 @@
 !TabView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TabView.st,v 1.8 1997-04-24 06:11:05 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TabView.st,v 1.9 1997-04-26 05:40:11 ca Exp $'
 ! !