--- a/ScrollBar.st Wed Oct 13 02:01:27 1993 +0100
+++ b/ScrollBar.st Wed Oct 13 02:04:14 1993 +0100
@@ -13,8 +13,7 @@
View subclass:#ScrollBar
instanceVariableNames:'thumb button1 button2 layout'
classVariableNames:'defaultScrollUpForm
- defaultScrollDownForm
- defaultLayout'
+ defaultScrollDownForm'
poolDictionaries:''
category:'Views-Interactors'
!
@@ -28,33 +27,18 @@
2 step-scroll buttons. when moved or stepped, it performs a
predefined action.
-%W% %E%
+$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.2 1993-10-13 01:03:34 claus Exp $
written spring/summer 89 by claus
'!
-!ScrollBar class methodsFor:'initialization'!
-
-initialize
- "read defaults"
-
- super initialize.
-
- "layout controls how buttons are positioned:
- #top puts them at top/left
- #bottom puts them at bottom/right
- #around puts them around thumb
- "
- defaultLayout := Resources at:'LAYOUT' default:#around
-! !
-
!ScrollBar class methodsFor:'defaults'!
scrollUpButtonForm:style
"answer the form used for the scrollUp Button"
defaultScrollUpForm isNil ifTrue:[
- defaultScrollUpForm := Form fromFile:(Resources at:'UP_BUTTON_FORM_FILE'
+ defaultScrollUpForm := Form fromFile:(self classResources at:'SCROLL_UP_BUTTON_FORM_FILE'
default:(style == #mswindows
ifTrue:['ScrollUp_win.xbm']
ifFalse:['ScrollUp.xbm'])
@@ -87,7 +71,7 @@
"retun the form used for the scrollDown Button"
defaultScrollDownForm isNil ifTrue:[
- defaultScrollDownForm := Form fromFile:(Resources at:'DOWN_BUTTON_FORM_FILE'
+ defaultScrollDownForm := Form fromFile:(self classResources at:'SCROLL_DOWN_BUTTON_FORM_FILE'
default:(style == #mswindows
ifTrue:['ScrollDn_win.xbm']
ifFalse:['ScrollDn.xbm'])
@@ -130,13 +114,15 @@
initialize
"setup; create the 2 buttons and a scroller"
- |bwn sep w h upForm downForm c|
+ |bwn sep w h upForm downForm c default|
super initialize.
"compute my extent from sub-components"
+
upForm := self class scrollUpButtonForm:style.
downForm := self class scrollDownButtonForm:style.
+
h := upForm height + downForm height +
(1 "self defaultBorderWidth" * 2) + (Scroller defaultExtent y).
w := (upForm width) max:(downForm width).
@@ -146,20 +132,15 @@
].
self extent:w @ h.
- style == #mswindows ifTrue:[
- layout := #around
- ] ifFalse:[
- layout := defaultLayout
- ].
-
- bwn := borderWidth negated.
+ bwn := borderWidth negated + margin.
self is3D ifTrue:[
sep := 1
] ifFalse:[
sep := 0
].
- button1 := Button form:(self class scrollUpButtonForm:style) in:self.
+ button1 := "Button form:(self class scrollUpButtonForm:style) in:self."
+ ArrowButton upIn:self.
button1 name:'UpButton'.
button1 borderWidth:borderWidth.
button1 autoRepeat.
@@ -169,7 +150,8 @@
thumb borderWidth:borderWidth.
].
- button2 := Button form:(self class scrollDownButtonForm:style) in:self.
+ button2 := "Button form:(self class scrollDownButtonForm:style) in:self."
+ ArrowButton downIn:self.
button2 name:'DownButton'.
button2 borderWidth:borderWidth.
button2 autoRepeat.
@@ -208,6 +190,22 @@
thumb viewGravity:#North
]
]
+!
+
+initStyle
+ |upForm downForm default|
+
+ super initStyle.
+
+ default := #bottom.
+ ((style == #mswindows) or:[style == #motif]) ifTrue:[
+ default := #around.
+ style == #motif ifTrue:[
+ self level:-1
+ ]
+ ].
+
+ layout := resources at:'SCROLLBAR_LAYOUT' default:default.
! !
!ScrollBar methodsFor:'accessing'!
@@ -302,7 +300,7 @@
"when my size changes, I have to resize/reposition the subviews"
|upHeight downHeight thumbHeight upAndDownHeight bwn sep sep2
- thumbWidth|
+ thumbWidth w|
button1 isNil ifTrue:[^ self].
thumb isNil ifTrue:[^ self].
@@ -311,7 +309,7 @@
upHeight := button1 height + borderWidth.
downHeight := button2 height + borderWidth.
upAndDownHeight := upHeight + downHeight.
- bwn := borderWidth negated.
+ bwn := borderWidth negated + margin.
self is3D ifTrue:[
sep := 1
] ifFalse:[
@@ -319,9 +317,14 @@
].
thumbHeight := height - upAndDownHeight - borderWidth - (sep * 3).
+"
((layout ~~ #top) and:[layout ~~ #bottom]) ifTrue:[
thumbHeight := thumbHeight - borderWidth
].
+"
+ layout == #around ifTrue:[
+ thumbHeight := thumbHeight + borderWidth
+ ].
"if I become too small, hide buttons and thumb"
@@ -355,12 +358,13 @@
"width of buttons is always my width"
- (width ~~ button1 width) ifTrue:[
- button1 width:width.
- button2 width:width
+ w := width - (margin * 2).
+ (w ~~ button1 width) ifTrue:[
+ button1 width:w.
+ button2 width:w
].
- thumbWidth := width.
+ thumbWidth := w.
style == #next ifTrue:[
thumbWidth := thumbWidth - (thumb borderWidth * 2).
thumbHeight := thumbHeight - 1
@@ -389,7 +393,8 @@
].
"buttons around thumb"
- button2 origin:(bwn @ (upHeight + thumbHeight + sep2 + borderWidth)).
- thumb extent:(thumbWidth @ thumbHeight).
+ button1 origin:(bwn @ bwn).
+ button2 origin:(bwn @ (upHeight + thumbHeight + sep2 "+ borderWidth")).
+ thumb extent:(thumbWidth @ (thumbHeight + margin)).
thumb origin:(bwn @ (upHeight - borderWidth + sep))
! !