TabWidget.st
changeset 351 6c46f186d84f
parent 350 cb420d4899ab
child 367 cff1a140978f
--- a/TabWidget.st	Mon Apr 07 17:13:39 1997 +0200
+++ b/TabWidget.st	Tue Apr 08 17:23:20 1997 +0200
@@ -26,14 +26,14 @@
 	privateIn:TabWidget
 !
 
-TabWidget subclass:#Folder
+TabWidget subclass:#Mac
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:TabWidget
 !
 
-TabWidget subclass:#Mac
+TabWidget subclass:#Folder
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
@@ -103,17 +103,18 @@
     style at:#lightColorUnselected
          put:((unselectedColor averageColorIn:(0@0 corner:7@7)) lightened on:aView device).
 
-    style at:#unselectedColor  put:unselectedColor.
-    style at:#selectedColor    put:selectedColor.
-    style at:#labelColor       put:(Color black).
+    style at:#unselectedColor    put:unselectedColor.
+    style at:#selectedColor      put:selectedColor.
+    style at:#labelColor         put:(Color black).
+    style at:#selectionAtBottom  put:false.  "/ true: selected tab always moved to bottom
 
-    style at:#vspace           put:0.      "/ vertical   tab space
-    style at:#hspace           put:0.      "/ horizontal tab space
-    style at:#leftOverLap      put:0.      "/ right tab overlaps left tab n pixels
-    style at:#lableTopInset    put:4.      "/ additional top label inset
-    style at:#labelBottomInset put:4.      "/ additional bottom inset
-    style at:#expandSelection  put:0@0.    "/ expand selection extent x y when raised
-    style at:#fixedLabelSize   put:false.  "/ true: label size derives from preferred extent
+    style at:#vspace             put:0.      "/ vertical   tab space
+    style at:#hspace             put:0.      "/ horizontal tab space
+    style at:#leftOverLap        put:0.      "/ right tab overlaps left tab n pixels
+    style at:#lableTopInset      put:4.      "/ additional top label inset
+    style at:#labelBottomInset   put:4.      "/ additional bottom inset
+    style at:#expandSelection    put:0@0.    "/ expand selection extent x y when raised
+    style at:#fixedLabelSize     put:false.  "/ true: label size derives from preferred extent
 
 
   ^ style
@@ -172,6 +173,10 @@
     inset := anInset
 !
 
+label
+    ^ label
+!
+
 labelOrigin
     "returns origin of label
     "
@@ -270,7 +275,7 @@
 
     x := aPoint x.
 
-    (x > origin x and:[aPoint y > origin y]) ifTrue:[
+    (x >= origin x and:[aPoint y >= origin y]) ifTrue:[
         ^ x < (origin x + extent x)
     ].
     ^ false.
@@ -318,10 +323,11 @@
 
     style := super tabStyleOn:aView.
 
-    style at:#fixedLabelSize   put:true.
-    style at:#tabLevel         put:2.
-    style at:#roundedEdges     put:true.
-    style at:#expandSelection  put:4@4.
+    style at:#fixedLabelSize     put:true.
+    style at:#tabLevel           put:2.
+    style at:#roundedEdges       put:true.
+    style at:#expandSelection    put:4@4.
+    style at:#selectionAtBottom  put:true.
 
   ^ style
 
@@ -418,6 +424,80 @@
 
 ! !
 
+!TabWidget::Mac class methodsFor:'accessing'!
+
+tabStyleOn:aView
+    |style col|
+
+    style := super tabStyleOn:aView.
+
+    style at:#fixedLabelSize     put:true.
+    style at:#leftOverLap        put:10.
+    style at:#selectionAtBottom  put:true.
+  ^ style
+
+
+! !
+
+!TabWidget::Mac class methodsFor:'constants'!
+
+rightInset
+    ^ 25 "/ 23
+! !
+
+!TabWidget::Mac methodsFor:'redefine'!
+
+preferredExtent
+
+  ^ (super preferredExtent) + ((self class rightInset) @ 0).
+!
+
+redrawSelected:isSelected
+    "full redraw; excluding the label
+    "
+    |polygon x y x1 eX eY color shadowColor lightColor|
+
+    isSelected ifFalse:[
+        color       := tabView styleAt:#unselectedColor.
+        shadowColor := tabView styleAt:#shadowColorUnselected.
+        lightColor  := tabView styleAt:#lightColorUnselected.
+    ] ifTrue:[
+        color       := tabView styleAt:#selectedColor.
+        shadowColor := tabView styleAt:#shadowColorSelected.
+        lightColor  := tabView styleAt:#lightColorSelected.
+    ].
+
+    polygon := Array new:5.
+    x  := origin x.
+    y  := origin y.
+    eX := x + extent x - 1.
+    eY := tabView extent y - inset.
+    x1 := eX - self class rightInset.
+
+    polygon at:1 put:(Point x:x      y:eY).
+    polygon at:2 put:(Point x:x      y:y).
+    polygon at:3 put:(Point x:x1     y:y).
+    polygon at:4 put:(Point x:eX     y:(y+extent y)).
+    polygon at:5 put:(Point x:eX     y:eY).
+
+    tabView paint:color.
+    tabView fillPolygon:polygon.
+
+    tabView paint:lightColor.
+    tabView displayLineFromX:x+1 y:eY toX:x+1 y:y+1.
+    tabView displayLineFromX:x+1 y:y+1 toX:x1-1 y:y+1.
+
+    tabView paintColor:#labelColor.
+    tabView displayPolygon:polygon.
+
+    isSelected ifFalse:[
+        tabView paint:shadowColor.
+        tabView displayLineFromX:x y:eY-1 toX:eX y:eY-1.
+    ]
+
+
+! !
+
 !TabWidget::Folder class methodsFor:'accessing'!
 
 tabStyleOn:aView
@@ -425,10 +505,10 @@
 
     style := super tabStyleOn:aView.
 
-    style at:#hspace           put:2.
-    style at:#vspace           put:2.
-    style at:#labelBottomInset put:10.
-    style at:#expandSelection  put:4@8.
+    style at:#hspace             put:2.
+    style at:#vspace             put:2.
+    style at:#labelBottomInset   put:10.
+    style at:#expandSelection    put:4@8.
 
   ^ style
 
@@ -512,81 +592,8 @@
 
 ! !
 
-!TabWidget::Mac class methodsFor:'accessing'!
-
-tabStyleOn:aView
-    |style col|
-
-    style := super tabStyleOn:aView.
-
-    style at:#fixedLabelSize   put:true.
-    style at:#leftOverLap      put:10.
-  ^ style
-
-
-! !
-
-!TabWidget::Mac class methodsFor:'constants'!
-
-rightInset
-    ^ 25 "/ 23
-! !
-
-!TabWidget::Mac methodsFor:'redefine'!
-
-preferredExtent
-
-  ^ (super preferredExtent) + ((self class rightInset) @ 0).
-!
-
-redrawSelected:isSelected
-    "full redraw; excluding the label
-    "
-    |polygon x y x1 eX eY color shadowColor lightColor|
-
-    isSelected ifFalse:[
-        color       := tabView styleAt:#unselectedColor.
-        shadowColor := tabView styleAt:#shadowColorUnselected.
-        lightColor  := tabView styleAt:#lightColorUnselected.
-    ] ifTrue:[
-        color       := tabView styleAt:#selectedColor.
-        shadowColor := tabView styleAt:#shadowColorSelected.
-        lightColor  := tabView styleAt:#lightColorSelected.
-    ].
-
-    polygon := Array new:5.
-    x  := origin x.
-    y  := origin y.
-    eX := x + extent x - 1.
-    eY := tabView extent y - inset.
-    x1 := eX - self class rightInset.
-
-    polygon at:1 put:(Point x:x      y:eY).
-    polygon at:2 put:(Point x:x      y:y).
-    polygon at:3 put:(Point x:x1     y:y).
-    polygon at:4 put:(Point x:eX     y:(y+extent y)).
-    polygon at:5 put:(Point x:eX     y:eY).
-
-    tabView paint:color.
-    tabView fillPolygon:polygon.
-
-    tabView paint:lightColor.
-    tabView displayLineFromX:x+1 y:eY toX:x+1 y:y+1.
-    tabView displayLineFromX:x+1 y:y+1 toX:x1-1 y:y+1.
-
-    tabView paintColor:#labelColor.
-    tabView displayPolygon:polygon.
-
-    isSelected ifFalse:[
-        tabView paint:shadowColor.
-        tabView displayLineFromX:x y:eY-1 toX:eX y:eY-1.
-    ]
-
-
-! !
-
 !TabWidget class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TabWidget.st,v 1.2 1997-04-07 15:13:39 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TabWidget.st,v 1.3 1997-04-08 15:23:20 ca Exp $'
 ! !