--- a/TabWidget.st Tue Aug 17 16:57:34 1999 +0200
+++ b/TabWidget.st Wed Aug 18 16:33:04 1999 +0200
@@ -20,14 +20,14 @@
category:'Views-Interactors'
!
-TabWidget subclass:#Mac
+TabWidget subclass:#Window
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
privateIn:TabWidget
!
-TabWidget subclass:#Window
+TabWidget subclass:#Mac
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
@@ -126,17 +126,19 @@
computeColorsOn:aView style:aStyle
"set colors dependent on selection color
"
- |unselectedColor selectedColor avgSelectedColor avgUnSelectedColor|
+ |device unselectedColor selectedColor avgSelectedColor avgUnSelectedColor|
+
+ device := aView device.
selectedColor := aView viewBackground.
unselectedColor := selectedColor lightened.
avgSelectedColor := selectedColor averageColorIn:(0@0 corner:7@7).
avgUnSelectedColor := unselectedColor averageColorIn:(0@0 corner:7@7).
- aStyle at:#shadowColorSelected put:(avgSelectedColor darkened on:aView device).
- aStyle at:#lightColorSelected put:(avgSelectedColor lightened on:aView device).
- aStyle at:#shadowColorUnselected put:(avgUnSelectedColor darkened on:aView device).
- aStyle at:#lightColorUnselected put:(avgUnSelectedColor lightened on:aView device).
+ aStyle at:#shadowColorSelected put:(avgSelectedColor darkened onDevice:device).
+ aStyle at:#lightColorSelected put:(avgSelectedColor lightened onDevice:device).
+ aStyle at:#shadowColorUnselected put:(avgUnSelectedColor darkened onDevice:device).
+ aStyle at:#lightColorUnselected put:(avgUnSelectedColor lightened onDevice:device).
aStyle at:#unselectedColor put:unselectedColor.
aStyle at:#selectedColor put:selectedColor.
@@ -148,20 +150,22 @@
computeColorsOn:aView style:aStyle selectionColor:aSelectedColor
"set colors dependent on selection color
"
- |unselectedColor selectedColor avgSelectedColor avgUnSelectedColor|
+ |device unselectedColor selectedColor avgSelectedColor avgUnSelectedColor|
"/ CG: this seems to be no longer needed ...
+ device := aView device.
+
unselectedColor := aView viewBackground.
selectedColor := unselectedColor lightened.
avgSelectedColor := selectedColor averageColorIn:(0@0 corner:7@7).
avgUnSelectedColor := unselectedColor averageColorIn:(0@0 corner:7@7).
- aStyle at:#shadowColorSelected put:(avgSelectedColor darkened on:aView device).
- aStyle at:#lightColorSelected put:(avgSelectedColor lightened on:aView device).
- aStyle at:#shadowColorUnselected put:(avgUnSelectedColor darkened on:aView device).
- aStyle at:#lightColorUnselected put:(avgUnSelectedColor lightened on:aView device).
+ aStyle at:#shadowColorSelected put:(avgSelectedColor darkened onDevice:device).
+ aStyle at:#lightColorSelected put:(avgSelectedColor lightened onDevice:device).
+ aStyle at:#shadowColorUnselected put:(avgUnSelectedColor darkened onDevice:device).
+ aStyle at:#lightColorUnselected put:(avgUnSelectedColor lightened onDevice:device).
aStyle at:#unselectedColor put:unselectedColor.
aStyle at:#selectedColor put:selectedColor.
@@ -385,7 +389,7 @@
label := printableLabel.
(model notNil and:[(fg := model foregroundColor) notNil]) ifTrue:[
fgColor = fg ifFalse:[
- fgColor := fg on:(tabView device)
+ fgColor := fg onDevice:(tabView device)
].
tabView paint:fgColor
] ifFalse:[
@@ -555,237 +559,6 @@
! !
-!TabWidget::Mac class methodsFor:'accessing'!
-
-tabStyleOn:aView
- |style|
-
- style := super tabStyleOn:aView.
- style at:#tabLevel put:2.
- ^ style.
-! !
-
-!TabWidget::Mac class methodsFor:'calculate dimensions'!
-
-validateDimensions:aStyle
- "validate dimensions for a style; could be redifined
- "
- |maxY maxX anchor lftIns|
-
- maxY := aStyle at:#maxY.
- maxX := (aStyle at:#maxX) - (aStyle at:#labelLeftInset).
- anchor := aStyle at:#labelAnchor.
- lftIns := maxY // 2.
-
- anchor x:lftIns.
-
- aStyle at:#maxX put:(maxX + lftIns + maxY).
- aStyle at:#rightCovered put:(maxY // 2).
-! !
-
-!TabWidget::Mac methodsFor:'drawing'!
-
-redrawAtBottom:isSelected
- "redraw tab at bottom of view
- "
- |origin corner level polygon x y x1 eX eY shadowColor lightColor|
-
- isSelected ifFalse:[
- lightColor := tabView styleAt:#lightColorUnselected.
- shadowColor := tabView styleAt:#shadowColorUnselected.
- tabView paint:(tabView styleAt:#unselectedColor).
- ] ifTrue:[
- lightColor := tabView styleAt:#lightColorSelected.
- shadowColor := tabView styleAt:#shadowColorSelected.
- tabView paint:(tabView styleAt:#selectedColor).
- ].
- polygon := Array new:5.
- origin := self computeOrigin.
- corner := self computeCorner.
- level := tabView styleAt:#tabLevel.
-
- x := origin x.
- y := origin y.
- eX := corner x.
- eY := corner y.
- x1 := eX - (tabView styleAt:#maxY).
-
- 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 fillPolygon:polygon.
- tabView paint:lightColor.
-
- 1 to:level do:[:i|
- "/ removed: cg
-"/ tabView displayLineFromX:x+1 y:y-i toX:x1+i y:y-i.
- tabView displayLineFromX:x+i y:y-1 toX:x+i y:1.
- ].
- tabView paint:shadowColor.
-
- "/ added: cg
- 1 to:(level-2) do:[:i|
- tabView displayLineFromX:x+1 y:y-i toX:x1+i y:y-i.
- ].
- tabView displayPolygon:polygon.
-
- isSelected ifFalse:[
- tabView displayLineFromX:x y:eY toX:eX y:eY.
- ]
-
- "Modified: / 21.5.1998 / 01:16:32 / cg"
-!
-
-redrawAtLeft:isSelected
- "redraw tab at left of view
- "
- |origin corner polygon level x y y1 eX eY shadowColor lightColor|
-
- isSelected ifFalse:[
- lightColor := tabView styleAt:#lightColorUnselected.
- shadowColor := tabView styleAt:#shadowColorUnselected.
- tabView paint:(tabView styleAt:#unselectedColor).
- ] ifTrue:[
- lightColor := tabView styleAt:#lightColorSelected.
- shadowColor := tabView styleAt:#shadowColorSelected.
- tabView paint:(tabView styleAt:#selectedColor).
- ].
- polygon := Array new:5.
- origin := self computeOrigin.
- corner := self computeCorner.
- level := tabView styleAt:#tabLevel.
-
- x := origin x.
- y := origin y.
- eX := corner x.
- eY := corner y.
- y1 := eY - (tabView styleAt:#maxY).
-
- polygon at:1 put:(Point x:eX y:y).
- polygon at:2 put:(Point x:x y:y).
- polygon at:3 put:(Point x:x y:y1).
- polygon at:4 put:(Point x:(x+extent x) y:eY).
- polygon at:5 put:(Point x:eX y:eY).
-
- tabView fillPolygon:polygon.
- tabView paint:lightColor.
-
- 1 to:level do:[:i|
- tabView displayLineFromX:eX y:y+i toX:x+2 y:y+i.
- tabView displayLineFromX:x+i y:y+1 toX:x+i y:y1+i.
- ].
- tabView paint:shadowColor.
- tabView displayPolygon:polygon.
-
- isSelected ifFalse:[
- tabView displayLineFromX:eX-1 y:y toX:eX-1 y:eY.
- ]
-!
-
-redrawAtRight:isSelected
- "redraw tab at right of view
- "
- |origin corner level polygon x y y1 eY shadowColor lightColor|
-
- isSelected ifFalse:[
- lightColor := tabView styleAt:#lightColorUnselected.
- shadowColor := tabView styleAt:#shadowColorUnselected.
- tabView paint:(tabView styleAt:#unselectedColor).
- ] ifTrue:[
- lightColor := tabView styleAt:#lightColorSelected.
- shadowColor := tabView styleAt:#shadowColorSelected.
- tabView paint:(tabView styleAt:#selectedColor).
- ].
- polygon := Array new:5.
- origin := self computeOrigin.
- corner := self computeCorner.
- level := tabView styleAt:#tabLevel.
-
- x := origin x.
- y := origin y.
- eY := corner y.
- y1 := eY - (tabView styleAt:#maxY).
-
- polygon at:1 put:(Point x:0 y:y).
- polygon at:2 put:(Point x:x y:y).
- polygon at:3 put:(Point x:x y:y1).
- polygon at:4 put:(Point x:(x-extent x) y:eY).
- polygon at:5 put:(Point x:0 y:eY).
-
- tabView fillPolygon:polygon.
- tabView paint:lightColor.
-
- 1 to:level do:[:i|
- tabView displayLineFromX:0 y:y+i toX:x-1 y:y+i.
- "/ removed: cg
-"/ tabView displayLineFromX:x-i y:y+1 toX:x-i y:y1+i.
- ].
- tabView paint:shadowColor.
- tabView displayPolygon:polygon.
-
- "/ added: cg
- 1 to:level-2 do:[:i|
- tabView displayLineFromX:x-i y:y+1 toX:x-i y:y1+i.
- ].
-
- isSelected ifFalse:[
- tabView displayLineFromX:0 y:y toX:0 y:eY.
- ]
-
- "Modified: / 21.5.1998 / 01:16:24 / cg"
-!
-
-redrawAtTop:isSelected
- "redraw tab at top of view
- "
- |origin corner level polygon x y x1 eX eY shadowColor lightColor|
-
- isSelected ifFalse:[
- lightColor := tabView styleAt:#lightColorUnselected.
- shadowColor := tabView styleAt:#shadowColorUnselected.
- tabView paint:(tabView styleAt:#unselectedColor).
- ] ifTrue:[
- lightColor := tabView styleAt:#lightColorSelected.
- shadowColor := tabView styleAt:#shadowColorSelected.
- tabView paint:(tabView styleAt:#selectedColor).
- ].
- polygon := Array new:5.
- origin := self computeOrigin.
- corner := self computeCorner.
- level := tabView styleAt:#tabLevel.
-
- x := origin x.
- y := origin y.
- eX := corner x - 1.
- eY := corner y.
- x1 := eX - (tabView styleAt:#maxY).
-
- 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 fillPolygon:polygon.
- tabView paint:lightColor.
-
- 1 to:level do:[:i|
- tabView displayLineFromX:x+i y:eY toX:x+i y:y+1.
- tabView displayLineFromX:x+1 y:y+i toX:x1+i y:y+i.
- ].
- tabView paint:shadowColor.
- tabView displayPolygon:polygon.
-
- isSelected ifFalse:[
- tabView displayLineFromX:x y:eY-1 toX:eX y:eY-1.
- ]
-
-
-! !
-
!TabWidget::Window class methodsFor:'accessing'!
tabStyleOn:aView
@@ -1077,8 +850,239 @@
].
! !
+!TabWidget::Mac class methodsFor:'accessing'!
+
+tabStyleOn:aView
+ |style|
+
+ style := super tabStyleOn:aView.
+ style at:#tabLevel put:2.
+ ^ style.
+! !
+
+!TabWidget::Mac class methodsFor:'calculate dimensions'!
+
+validateDimensions:aStyle
+ "validate dimensions for a style; could be redifined
+ "
+ |maxY maxX anchor lftIns|
+
+ maxY := aStyle at:#maxY.
+ maxX := (aStyle at:#maxX) - (aStyle at:#labelLeftInset).
+ anchor := aStyle at:#labelAnchor.
+ lftIns := maxY // 2.
+
+ anchor x:lftIns.
+
+ aStyle at:#maxX put:(maxX + lftIns + maxY).
+ aStyle at:#rightCovered put:(maxY // 2).
+! !
+
+!TabWidget::Mac methodsFor:'drawing'!
+
+redrawAtBottom:isSelected
+ "redraw tab at bottom of view
+ "
+ |origin corner level polygon x y x1 eX eY shadowColor lightColor|
+
+ isSelected ifFalse:[
+ lightColor := tabView styleAt:#lightColorUnselected.
+ shadowColor := tabView styleAt:#shadowColorUnselected.
+ tabView paint:(tabView styleAt:#unselectedColor).
+ ] ifTrue:[
+ lightColor := tabView styleAt:#lightColorSelected.
+ shadowColor := tabView styleAt:#shadowColorSelected.
+ tabView paint:(tabView styleAt:#selectedColor).
+ ].
+ polygon := Array new:5.
+ origin := self computeOrigin.
+ corner := self computeCorner.
+ level := tabView styleAt:#tabLevel.
+
+ x := origin x.
+ y := origin y.
+ eX := corner x.
+ eY := corner y.
+ x1 := eX - (tabView styleAt:#maxY).
+
+ 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 fillPolygon:polygon.
+ tabView paint:lightColor.
+
+ 1 to:level do:[:i|
+ "/ removed: cg
+"/ tabView displayLineFromX:x+1 y:y-i toX:x1+i y:y-i.
+ tabView displayLineFromX:x+i y:y-1 toX:x+i y:1.
+ ].
+ tabView paint:shadowColor.
+
+ "/ added: cg
+ 1 to:(level-2) do:[:i|
+ tabView displayLineFromX:x+1 y:y-i toX:x1+i y:y-i.
+ ].
+ tabView displayPolygon:polygon.
+
+ isSelected ifFalse:[
+ tabView displayLineFromX:x y:eY toX:eX y:eY.
+ ]
+
+ "Modified: / 21.5.1998 / 01:16:32 / cg"
+!
+
+redrawAtLeft:isSelected
+ "redraw tab at left of view
+ "
+ |origin corner polygon level x y y1 eX eY shadowColor lightColor|
+
+ isSelected ifFalse:[
+ lightColor := tabView styleAt:#lightColorUnselected.
+ shadowColor := tabView styleAt:#shadowColorUnselected.
+ tabView paint:(tabView styleAt:#unselectedColor).
+ ] ifTrue:[
+ lightColor := tabView styleAt:#lightColorSelected.
+ shadowColor := tabView styleAt:#shadowColorSelected.
+ tabView paint:(tabView styleAt:#selectedColor).
+ ].
+ polygon := Array new:5.
+ origin := self computeOrigin.
+ corner := self computeCorner.
+ level := tabView styleAt:#tabLevel.
+
+ x := origin x.
+ y := origin y.
+ eX := corner x.
+ eY := corner y.
+ y1 := eY - (tabView styleAt:#maxY).
+
+ polygon at:1 put:(Point x:eX y:y).
+ polygon at:2 put:(Point x:x y:y).
+ polygon at:3 put:(Point x:x y:y1).
+ polygon at:4 put:(Point x:(x+extent x) y:eY).
+ polygon at:5 put:(Point x:eX y:eY).
+
+ tabView fillPolygon:polygon.
+ tabView paint:lightColor.
+
+ 1 to:level do:[:i|
+ tabView displayLineFromX:eX y:y+i toX:x+2 y:y+i.
+ tabView displayLineFromX:x+i y:y+1 toX:x+i y:y1+i.
+ ].
+ tabView paint:shadowColor.
+ tabView displayPolygon:polygon.
+
+ isSelected ifFalse:[
+ tabView displayLineFromX:eX-1 y:y toX:eX-1 y:eY.
+ ]
+!
+
+redrawAtRight:isSelected
+ "redraw tab at right of view
+ "
+ |origin corner level polygon x y y1 eY shadowColor lightColor|
+
+ isSelected ifFalse:[
+ lightColor := tabView styleAt:#lightColorUnselected.
+ shadowColor := tabView styleAt:#shadowColorUnselected.
+ tabView paint:(tabView styleAt:#unselectedColor).
+ ] ifTrue:[
+ lightColor := tabView styleAt:#lightColorSelected.
+ shadowColor := tabView styleAt:#shadowColorSelected.
+ tabView paint:(tabView styleAt:#selectedColor).
+ ].
+ polygon := Array new:5.
+ origin := self computeOrigin.
+ corner := self computeCorner.
+ level := tabView styleAt:#tabLevel.
+
+ x := origin x.
+ y := origin y.
+ eY := corner y.
+ y1 := eY - (tabView styleAt:#maxY).
+
+ polygon at:1 put:(Point x:0 y:y).
+ polygon at:2 put:(Point x:x y:y).
+ polygon at:3 put:(Point x:x y:y1).
+ polygon at:4 put:(Point x:(x-extent x) y:eY).
+ polygon at:5 put:(Point x:0 y:eY).
+
+ tabView fillPolygon:polygon.
+ tabView paint:lightColor.
+
+ 1 to:level do:[:i|
+ tabView displayLineFromX:0 y:y+i toX:x-1 y:y+i.
+ "/ removed: cg
+"/ tabView displayLineFromX:x-i y:y+1 toX:x-i y:y1+i.
+ ].
+ tabView paint:shadowColor.
+ tabView displayPolygon:polygon.
+
+ "/ added: cg
+ 1 to:level-2 do:[:i|
+ tabView displayLineFromX:x-i y:y+1 toX:x-i y:y1+i.
+ ].
+
+ isSelected ifFalse:[
+ tabView displayLineFromX:0 y:y toX:0 y:eY.
+ ]
+
+ "Modified: / 21.5.1998 / 01:16:24 / cg"
+!
+
+redrawAtTop:isSelected
+ "redraw tab at top of view
+ "
+ |origin corner level polygon x y x1 eX eY shadowColor lightColor|
+
+ isSelected ifFalse:[
+ lightColor := tabView styleAt:#lightColorUnselected.
+ shadowColor := tabView styleAt:#shadowColorUnselected.
+ tabView paint:(tabView styleAt:#unselectedColor).
+ ] ifTrue:[
+ lightColor := tabView styleAt:#lightColorSelected.
+ shadowColor := tabView styleAt:#shadowColorSelected.
+ tabView paint:(tabView styleAt:#selectedColor).
+ ].
+ polygon := Array new:5.
+ origin := self computeOrigin.
+ corner := self computeCorner.
+ level := tabView styleAt:#tabLevel.
+
+ x := origin x.
+ y := origin y.
+ eX := corner x - 1.
+ eY := corner y.
+ x1 := eX - (tabView styleAt:#maxY).
+
+ 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 fillPolygon:polygon.
+ tabView paint:lightColor.
+
+ 1 to:level do:[:i|
+ tabView displayLineFromX:x+i y:eY toX:x+i y:y+1.
+ tabView displayLineFromX:x+1 y:y+i toX:x1+i y:y+i.
+ ].
+ tabView paint:shadowColor.
+ tabView displayPolygon:polygon.
+
+ isSelected ifFalse:[
+ 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.20 1999-05-20 17:29:18 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/TabWidget.st,v 1.21 1999-08-18 14:33:04 cg Exp $'
! !