"
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
Scroller subclass:#Slider
instanceVariableNames:'sliderHeight'
classVariableNames: ''
poolDictionaries:''
category:'Views-Interactors'
!
Slider comment:'
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
$Header: /cvs/stx/stx/libwidg2/Slider.st,v 1.6 1994-10-10 03:13:40 claus Exp $
'!
!Slider class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
version
"
$Header: /cvs/stx/stx/libwidg2/Slider.st,v 1.6 1994-10-10 03:13:40 claus Exp $
"
!
documentation
"
this class implements sliders - which are simply scrollers
with a constant thumbHeight and a sligthly different way of
drawing.
"
! !
!Slider methodsFor:'initialization'!
initialize
sliderHeight := (self verticalPixelPerMillimeter:10) rounded.
super initialize.
thumbHeight := 0
!
initStyle
super initStyle.
tallyMarks := StyleSheet at:'sliderNTallyMarks' default:1.
tallyLevel := StyleSheet at:'sliderTallyLevel' default:-1.
! !
!Slider methodsFor:'accessing'!
thumbHeight
"redefined since a slider has no height - just origin"
^ nil
! !
!Slider methodsFor:'private'!
absFromPercent:percent
"given a percentage, compute number of pixels"
^ ((percent * (height - sliderHeight - (margin * 2))) / 100) rounded
!
percentFromAbs:absValue
"given a number of pixels, compute percentage"
|val|
val := absValue / (height - sliderHeight - (margin * 2)) * 100.
val < 0 ifTrue:[^ 0].
val > 100 ifTrue:[^ 100].
^ val
!
computeThumbFrame
"redefined, since the thumb-height stays constant"
|nh nw ny nx|
thumbHeight := 0.
ny := (self absFromPercent:thumbOrigin) + margin.
nh := sliderHeight.
nx := margin + inset.
nw := width - (2 * nx).
"
do not create new Rectangle if its the same anyway
"
thumbFrame notNil ifTrue:[
(ny == thumbFrame top) ifTrue:[
(nx == thumbFrame left) ifTrue:[
(nh == thumbFrame height) ifTrue:[
(nw == thumbFrame width) ifTrue:[ ^ self]
]
]
]
].
thumbFrame := Rectangle left:nx top:ny width:nw height:nh
! !