--- a/ScrollBar.st Fri Mar 01 22:28:32 1996 +0100
+++ b/ScrollBar.st Fri Mar 01 22:35:23 1996 +0100
@@ -69,136 +69,135 @@
"extract values from the styleSheet and cache them in class variables"
<resource: #style (#scrollBarButtonPositions #scrollBarLevel
- #scrollBarScrollerBordered #scrollBarElementSpacing)>
+ #scrollBarScrollerBordered #scrollBarElementSpacing)>
DefaultButtonPositions := StyleSheet at:'scrollBarButtonPositions' default:#bottom.
DefaultLevel := StyleSheet at:'scrollBarLevel'.
DefaultScrollerBordered := StyleSheet at:'scrollBarScrollerBordered' default:false.
DefaultElementSpacing := StyleSheet at:'scrollBarElementSpacing'
- default:(StyleSheet is3D ifTrue:[1] ifFalse:[0]).
+ default:(StyleSheet is3D ifTrue:[1] ifFalse:[0]).
"Modified: 1.3.1996 / 13:46:29 / cg"
! !
!ScrollBar methodsFor:'accessing'!
-v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'+' downButtonLabel:'-'.
- v open
- "
+downButton
+ "return the down-button
+ (Please: only use this direct access for special applications)"
- "also possible :
- |v|
+ ^ button2
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'u' downButtonLabel:'d'.
- v open
"
-
- "BAD example:
|v|
v := ScrollableView for:EditTextView.
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
- v open
- "
-
- "Modified: 1.3.1996 / 19:06:50 / cg"
-!
-
-c/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'+' downButtonLabel:'-'.
+ v scrollBar upButton activeForegroundColor:Color red.
+ v scrollBar downButton activeForegroundColor:Color red.
v open
"
+!
- "also possible :
- |v|
+setThumbFor:aView
+ "adjust thumb for aView
+ (i.e. adjust thumbs origin & size for views size & views contents).
+ This is forwarded to the scroller here."
+
+ thumb setThumbFor:aView.
+ self enableDisableButtons
+!
+
+setThumbHeightFor:aView
+ "adjust thumbs height for aViews size & contents.
+ This is forwarded to the scroller here."
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'u' downButtonLabel:'d'.
- v open
+ thumb setThumbHeightFor:aView.
+ self enableDisableButtons
+!
+
+setThumbOriginFor:aView
+ "adjust thumbs origin for aViews size & contents.
+ This is forwarded to the scroller here."
+
+ thumb setThumbOriginFor:aView.
+ self enableDisableButtons
+!
+
+thumb
+ "return the thumb (i.e. the scroller subview)
+ (Please: only use this direct access for special applications)"
+
+ ^ thumb
+
"
-
- "BAD example:
|v|
v := ScrollableView for:EditTextView.
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
- v open
- "
-
- "Modified: 1.3.1996 / 19:06:50 / cg"
-!
-
-ownButtonLabel:'-'.
+ v scrollBar thumb thumbColor:(Color red).
v open
"
- "also possible :
- |v|
+ "Modified: 1.3.1996 / 19:15:50 / cg"
+!
+
+thumbColor:aColor
+ "set the thumbs color"
+
+ thumb thumbColor:aColor
+!
+
+thumbHeight
+ "return height of thumb in percent"
+
+ ^ thumb thumbHeight
+!
+
+thumbHeight:newHeight
+ "set height of thumb in percent"
+
+ thumb thumbHeight:newHeight.
+ self enableDisableButtons
+!
+
+thumbOrigin
+ "return position of (top of) thumb in percent"
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'u' downButtonLabel:'d'.
- v open
+ ^ thumb thumbOrigin
+!
+
+thumbOrigin:newOrigin
+ "set position of (top of) thumb in percent"
+
+ thumb thumbOrigin:newOrigin.
+ self enableDisableButtons
+!
+
+thumbOrigin:newOrigin thumbHeight:newHeight
+ "set origin and height of thumb (both in percent)"
+
+ thumb thumbOrigin:newOrigin thumbHeight:newHeight.
+ self enableDisableButtons
+!
+
+upButton
+ "return the up-button
+ (Please: only use this direct access for special applications)"
+
+ ^ button1
+
"
-
- "BAD example:
|v|
v := ScrollableView for:EditTextView.
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
- v open
- "
-
- "Modified: 1.3.1996 / 19:06:50 / cg"
-!
-
-edView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'u' downButtonLabel:'d'.
- v open
- "
-
- "BAD example:
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
+ v scrollBar upButton foregroundColor:(Color red).
+ v scrollBar upButton enteredForegroundColor:(Color red lightened).
+ v scrollBar downButton foregroundColor:(Color green).
+ v scrollBar downButton enteredForegroundColor:(Color green lightened).
v open
"
-
- "Modified: 1.3.1996 / 19:06:50 / cg"
-!
-
-abel:'u' downButtonLabel:'d'.
- v open
- "
-
- "BAD example:
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
- v open
- "
-
- "Modified: 1.3.1996 / 19:06:50 / cg"
-!
-
-ew contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
- v open
- "
-
- "Modified: 1.3.1996 / 19:06:50 / cg"
!
upButtonLabel:label1 downButtonLabel:label2
@@ -242,157 +241,181 @@
!ScrollBar methodsFor:'accessing-behavior'!
-"return the down-button
- (Please: only use this direct access for special applications)"
-
- ^ button2
-
- "
- |v|
+asynchronousOperation
+ "set asynchronous-mode - scroll action is performed after movement
+ of scroller (i.e. when mouse-button is finally released).
+ This is forwarded to the scroller here."
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButton activeForegroundColor:Color red.
- v scrollBar downButton activeForegroundColor:Color red.
- v open
- "
-
- "Modified: 1.3.1996 / 19:04:43 / cg"
+ thumb asynchronousOperation
!
-EntireFile).
- v scrollBar upButton activeForegroundColor:Color red.
- v scrollBar downButton activeForegroundColor:Color red.
- v open
- "
-
- "Modified: 1.3.1996 / 19:04:43 / cg"
-!
-
-996 / 19:04:43 / cg"
-!
+scrollAction:aBlock
+ "set the action, aBlock to be performed when the scroller is moved.
+ This is forwarded to the scroller here."
-al applications)"
-
- ^ thumb
-
- "
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar thumb thumbColor:(Color red).
- v open
- "
-
- "Modified: 1.3.1996 / 19:15:50 / cg"
+ thumb scrollAction:aBlock
!
-asswd' asFilename contentsOfEntireFile).
- v scrollBar thumb thumbColor:(Color red).
- v open
- "
-
- "Modified: 1.3.1996 / 19:15:50 / cg"
-! !
-
-!ScrollBar methodsFor:'accessing-components'!
-
-downButton
- "return the down-button
- (Please: only use this direct access for special applications)"
+scrollDownAction:aBlock
+ "set the action, aBlock to be performed when the down-button is pressed."
- ^ button2
-
- "
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButton activeForegroundColor:Color red.
- v scrollBar downButton activeForegroundColor:Color red.
- v open
- "
-
- "Modified: 1.3.1996 / 19:04:43 / cg"
+ button2 action:aBlock
!
-thumb
- "return the thumb (i.e. the scroller subview)
- (Please: only use this direct access for special applications)"
-
- ^ thumb
+scrollUpAction:aBlock
+ "set the action, aBlock to be performed when the up-button is pressed."
- "
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar thumb thumbColor:(Color red).
- v open
- "
-
- "Modified: 1.3.1996 / 19:15:50 / cg"
+ button1 action:aBlock
!
-upButton
- "return the up-button
- (Please: only use this direct access for special applications)"
-
- ^ button1
-
- "
- |v|
+synchronousOperation
+ "set synchronous-mode - scroll action is performed for every movement
+ of scroller.
+ This is forwarded to the scroller here."
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButton foregroundColor:(Color red).
- v scrollBar upButton enteredForegroundColor:(Color red lightened).
- v scrollBar downButton foregroundColor:(Color green).
- v scrollBar downButton enteredForegroundColor:(Color green lightened).
- v open
- "
-
- "Modified: 1.3.1996 / 19:04:48 / cg"
+ thumb synchronousOperation
! !
!ScrollBar methodsFor:'change & update'!
-l applications)"
-
- ^ button1
-
- "
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButton foregroundColor:(Color red).
- v scrollBar upButton enteredForegroundColor:(Color red lightened).
- v scrollBar downButton foregroundColor:(Color green).
- v scrollBar downButton enteredForegroundColor:(Color green lightened).
- v open
- "
-
- "Modified: 1.3.1996 / 19:04:48 / cg"
+update:something with:aParameter from:changedObject
+ changedObject == thumb ifTrue:[
+ self enableDisableButtons
+ ]
! !
!ScrollBar methodsFor:'events'!
-tireFile).
- v scrollBar upButton foregroundColor:(Color red).
- v scrollBar upButton enteredForegroundColor:(Color red lightened).
- v scrollBar downButton foregroundColor:(Color green).
- v scrollBar downButton enteredForegroundColor:(Color green lightened).
- v open
- "
+sizeChanged:how
+ "when my size changes, I have to resize/reposition the subviews.
+ Also, if I became too small, hide thumb/buttons."
+
+ |upHeight downHeight thumbHeight upAndDownHeight bwn sep2
+ thumbWidth w style b1Hidden b2Hidden thumbHidden bY|
+
+ button1 isNil ifTrue:[^ self].
+ thumb isNil ifTrue:[^ self].
+ button2 isNil ifTrue:[^ self].
+
+ style := styleSheet name.
+
+ upHeight := button1 height + borderWidth.
+ downHeight := button2 height + borderWidth.
+ upAndDownHeight := upHeight + downHeight.
+ bwn := borderWidth negated + margin.
+
+ thumbHeight := height - upAndDownHeight - borderWidth - (elementSpacing * 3).
+"
+ ((buttonLayout ~~ #top) and:[buttonLayout ~~ #bottom]) ifTrue:[
+ thumbHeight := thumbHeight - borderWidth
+ ].
+"
+ buttonLayout == #around ifTrue:[
+ thumbHeight := thumbHeight + borderWidth
+ ].
+
+ "if I become too small, hide buttons and thumb"
- "Modified: 1.3.1996 / 19:04:48 / cg"
-! !
+ height < upAndDownHeight ifTrue:[
+ b1Hidden := b2Hidden := thumbHidden := true.
+ ] ifFalse:[
+ b1Hidden := b2Hidden := thumbHidden := false.
+ ].
+
+ (thumbHeight < 10) ifTrue:[
+ thumbHidden := true.
+ ] ifFalse:[
+ thumbHidden := false.
+ ].
-!ScrollBar methodsFor:'forced scroll'!
+ button1 hiddenOnRealize:b1Hidden.
+ b1Hidden ifTrue:[
+ button1 unrealize
+ ] ifFalse:[
+ shown ifTrue:[button1 realize]
+ ].
+ button2 hiddenOnRealize:b1Hidden.
+ b2Hidden ifTrue:[
+ button2 unrealize
+ ] ifFalse:[
+ shown ifTrue:[button2 realize]
+ ].
+ thumb hiddenOnRealize:thumbHidden.
+ thumbHidden ifTrue:[
+ thumb unrealize
+ ] ifFalse:[
+ shown ifTrue:[thumb realize]
+ ].
+
+ "width of buttons is always my width"
-ue:[
+ w := width - (margin * 2).
+ (w ~~ button1 width) ifTrue:[
+ button1 width:w.
+ button2 width:w
+ ].
+
+ thumbWidth := w.
+ style == #next ifTrue:[
+ thumbWidth := thumbWidth - (thumb borderWidth * 2).
+ thumbHeight := thumbHeight - 1
+ ].
+ style == #motif ifTrue:[
+ thumbHeight := thumbHeight - margin
+ ].
+
+ "
+ a kludge: views with width or height of 0 are illegal
+ avoid error from view-creation (it will be hidden anyway)
+ "
+ thumbHeight <= 0 ifTrue:[
+ thumbHeight := 1
+ ].
+
+ (buttonLayout == #top) ifTrue:[
+ "buttons at top"
+ thumb extent:(thumbWidth @ thumbHeight).
+ ^ self
+ ].
+
+ sep2 := elementSpacing * 2.
+ (buttonLayout == #bottom) ifTrue:[
+ "buttons at bottom"
+"/
+"/ XX: I thought, that viewGravity shuld fix things automatically
+"/ XX: it seems not to do it (or I misused it ;-)
+"/ XX: anyway, viewGravity is an X special feature which is probably
+"/ XX: not available with other windowing systems. Therefore,
+"/ XX: the viewGravity depending code below is disabled.
+"/ XX: resize is somewhat slower, though.
+
+ thumbHeight := thumbHeight + borderWidth.
+"/ XX thumbHidden ifTrue:[
+"/ XX bY := elementSpacing
+"/ XX ] ifFalse:[
+ bY := thumbHeight + sep2.
+"/ XX ].
+"XX" button1 viewGravity:#North.
+"XX" button2 viewGravity:#North.
+ (how == #smaller) ifTrue:[
+ thumb extent:(thumbWidth @ thumbHeight).
+"XX" button1 origin:(bwn @ (thumbHeight + sep2)).
+"XX" button2 origin:(bwn @ (thumbHeight + sep2 + upHeight))
+ ] ifFalse:[
+ button1 origin:(bwn @ bY).
+ button2 origin:(bwn @ (bY + upHeight)).
+ thumb extent:(thumbWidth @ thumbHeight)
+ ].
+ ^ self
+ ].
+ "buttons around thumb"
+
+ style == #motif ifTrue:[
+ sep2 := sep2 + 1
+ ].
+ button1 origin:(bwn @ bwn).
+
+ style == #os2 ifTrue:[
button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - margin "+ borderWidth")).
thumb extent:(thumbWidth @ (thumbHeight - margin - margin "+ margin - (margin // 2)")).
thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing + margin))
@@ -401,38 +424,47 @@
thumb extent:(thumbWidth @ (thumbHeight + margin - (margin // 2))).
thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing))
].
-!
-
-sep2 - margin "+ borderWidth")).
- thumb extent:(thumbWidth @ (thumbHeight - margin - margin "+ margin - (margin // 2)")).
- thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing + margin))
- ] ifFalse:[
- button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - (margin // 2) "+ borderWidth")).
- thumb extent:(thumbWidth @ (thumbHeight + margin - (margin // 2))).
- thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing))
- ].
! !
-!ScrollBar methodsFor:'initialization'!
+!ScrollBar methodsFor:'forced scroll'!
+
+pageDown
+ "page down/right"
+
+ thumb pageDown
+!
-] ifFalse:[
- button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - (margin // 2) "+ borderWidth")).
- thumb extent:(thumbWidth @ (thumbHeight + margin - (margin // 2))).
- thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing))
- ].
-!
+pageUp
+ "page up/left"
+
+ thumb pageUp
+! !
+
+!ScrollBar methodsFor:'initialization'!
defaultExtent
"compute my extent from sub-components"
^ self preferredExtent
+
"Created: 1.3.1996 / 19:22:11 / cg"
!
-@ (thumbHeight + margin - (margin // 2))).
- thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing))
+createElements
+ button1 := ArrowButton upIn:self.
+ button2 := ArrowButton downIn:self.
+ thumb := Scroller in:self.
+!
+
+initStyle
+ super initStyle.
+
+ buttonLayout := DefaultButtonPositions.
+ DefaultLevel notNil ifTrue:[
+ self level:DefaultLevel
].
+ elementSpacing := DefaultElementSpacing
!
initialize
@@ -445,7 +477,7 @@
self createElements.
(styleSheet at:'scrollBarDisableButtons' default:false) ifTrue:[
- thumb addDependent:self
+ thumb addDependent:self
].
button1 autoRepeat:true.
@@ -453,85 +485,69 @@
button1 borderWidth:borderWidth.
DefaultScrollerBordered ifFalse:[
- thumb borderWidth:borderWidth.
+ thumb borderWidth:borderWidth.
].
button2 borderWidth:borderWidth.
style := styleSheet name.
((style = #iris) and:[Display hasGreyscales]) ifTrue:[
- "have to change some of Buttons defaults"
- clr := (Color grey:25) on:device.
- button1 offLevel:2.
- button2 offLevel:2.
- button1 foregroundColor:clr.
- button1 activeForegroundColor:clr.
- button1 enteredForegroundColor:clr.
- button2 foregroundColor:clr.
- button2 activeForegroundColor:clr.
- button2 enteredForegroundColor:clr.
+ "have to change some of Buttons defaults"
+ clr := (Color grey:25) on:device.
+ button1 offLevel:2.
+ button2 offLevel:2.
+ button1 foregroundColor:clr.
+ button1 activeForegroundColor:clr.
+ button1 enteredForegroundColor:clr.
+ button2 foregroundColor:clr.
+ button2 activeForegroundColor:clr.
+ button2 enteredForegroundColor:clr.
].
self setElementPositions.
style = #motif ifTrue:[
- clr := thumb thumbColor.
- button1 foregroundColor:clr.
- button2 foregroundColor:clr.
-
- clr := thumb viewBackground.
- button1 viewBackground:clr.
- button2 viewBackground:clr.
- button1 backgroundColor:clr.
- button2 backgroundColor:clr.
- button1 activeBackgroundColor:clr.
- button2 activeBackgroundColor:clr.
- device hasGreyscales ifFalse:[
- button1 activeForegroundColor:Black.
- button2 activeForegroundColor:Black.
- ]
- ]
+ clr := thumb thumbColor.
+ button1 foregroundColor:clr.
+ button2 foregroundColor:clr.
- "Modified: 1.3.1996 / 19:22:47 / cg"
-!
-
-button1 foregroundColor:clr.
- button2 foregroundColor:clr.
-
- clr := thumb viewBackground.
- button1 viewBackground:clr.
- button2 viewBackground:clr.
- button1 backgroundColor:clr.
- button2 backgroundColor:clr.
- button1 activeBackgroundColor:clr.
- button2 activeBackgroundColor:clr.
- device hasGreyscales ifFalse:[
- button1 activeForegroundColor:Black.
- button2 activeForegroundColor:Black.
- ]
+ clr := thumb viewBackground.
+ button1 viewBackground:clr.
+ button2 viewBackground:clr.
+ button1 backgroundColor:clr.
+ button2 backgroundColor:clr.
+ button1 activeBackgroundColor:clr.
+ button2 activeBackgroundColor:clr.
+ device hasGreyscales ifFalse:[
+ button1 activeForegroundColor:Black.
+ button2 activeForegroundColor:Black.
+ ]
]
"Modified: 9.2.1996 / 22:42:16 / cg"
!
-clr := thumb viewBackground.
- button1 viewBackground:clr.
- button2 viewBackground:clr.
- button1 backgroundColor:clr.
- button2 backgroundColor:clr.
- button1 activeBackgroundColor:clr.
- button2 activeBackgroundColor:clr.
- device hasGreyscales ifFalse:[
- button1 activeForegroundColor:Black.
- button2 activeForegroundColor:Black.
- ]
- ]
+reinitialize
+ super reinitialize.
+ self setElementPositions.
+!
+
+setElementPositions
+ "position sub-components"
+
+ |bwn|
- "Modified: 9.2.1996 / 22:42:16 / cg"
-! !
+ bwn := borderWidth negated + margin.
-!ScrollBar methodsFor:'private'!
-
-elementSpacing)).
+ (buttonLayout == #top) ifTrue:[
+ button1 origin:(bwn @ bwn).
+ button1 viewGravity:#North.
+ button2 origin:(bwn @ (button1 height)).
+ button2 viewGravity:#North.
+ thumb origin:(bwn @ (button1 height
+ + borderWidth
+ + button2 height
+ + elementSpacing
+ + elementSpacing)).
thumb viewGravity:#North.
^ self
].
@@ -551,60 +567,18 @@
"/ button2 viewGravity:#North.
thumb origin:(bwn @ (button1 height + elementSpacing)).
thumb viewGravity:#North
-!
-
-mbOrigin:newOrigin thumbHeight:newHeight.
- self enableDisableButtons
! !
-!ScrollBar methodsFor:'private scrollView interface'!
-
-"set position of (top of) thumb in percent"
-
- thumb thumbOrigin:newOrigin.
- self enableDisableButtons
-!
-
-sizes, this only makes sense with
- single-character strings or small bitmaps."
-
- button1 label:label1.
- button2 label:label2.
- self setElementPositions.
-
- "not bad:
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'+' downButtonLabel:'-'.
- v open
- "
+!ScrollBar methodsFor:'private'!
- "also possible :
- |v|
-
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'u' downButtonLabel:'d'.
- v open
- "
-
- "BAD example:
- |v|
+enableDisableButtons
+ "only used with styles which disable their buttons if the
+ thumb is at either end. Check where the thumb is and enable/disable
+ as appropriate."
- v := ScrollableView for:EditTextView.
- v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
- v scrollBar upButtonLabel:'up' downButtonLabel:'down'.
- v open
- "
+ |e1 e2 th to|
- "Modified: 1.3.1996 / 19:06:50 / cg"
-! !
-
-!ScrollBar methodsFor:'queries'!
-
-et at:'scrollBarDisableButtons' default:false) ifFalse:[^ self].
+ (styleSheet at:'scrollBarDisableButtons' default:false) ifFalse:[^ self].
e1 := e2 := true.
(th := thumb thumbHeight) notNil ifTrue:[
@@ -625,8 +599,52 @@
e2 ifTrue:[button2 enable] ifFalse:[button2 disable].
! !
+!ScrollBar methodsFor:'queries'!
+
+preferredExtent
+ "compute my extent from sub-components"
+
+ |w h upForm downForm
+ upHeight "{ Class: SmallInteger }"
+ downHeight "{ Class: SmallInteger }"
+ upWidth downWidth style|
+
+ "
+ need fix - this is a kludge;
+ the if should not be needed ...
+ "
+ style := styleSheet name.
+ style == #mswindows ifTrue:[
+ w := button1 width max:button2 width.
+ h := button1 height + button2 height + (Scroller defaultExtent y).
+ ] ifFalse:[
+ upForm := ArrowButton upArrowButtonForm:style on:device.
+ downForm := ArrowButton downArrowButtonForm:style on:device.
+ upForm isNil ifTrue:[
+ upHeight := upWidth := 16.
+ ] ifFalse:[
+ upHeight := upForm height.
+ upWidth := upForm width
+ ].
+ downForm isNil ifTrue:[
+ downHeight := downWidth := 16
+ ] ifFalse:[
+ downHeight := downForm height.
+ downWidth := downForm width
+ ].
+ h := upHeight + downHeight + (1 * 2) + (Scroller defaultExtent y).
+ w := upWidth max:downWidth.
+ style ~~ #normal ifTrue:[
+ h := h + 4.
+ w := w + 4
+ ].
+ ].
+
+ ^ w @ h.
+! !
+
!ScrollBar class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.24 1996-03-01 18:47:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.25 1996-03-01 21:35:23 cg Exp $'
! !