"
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.
"
HorizontalScroller subclass:#HorizontalSlider
instanceVariableNames:'sliderHeight'
classVariableNames: ''
poolDictionaries:''
category:'Views-Interactors'
!
HorizontalSlider comment:'
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
$Header: /cvs/stx/stx/libwidg2/HorizontalSlider.st,v 1.2 1994-10-10 03:13:15 claus Exp $
'!
!HorizontalSlider 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/HorizontalSlider.st,v 1.2 1994-10-10 03:13:15 claus Exp $
"
!
documentation
"
this class implements horizontal sliders.
"
! !
!HorizontalSlider 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.
! !
!HorizontalSlider methodsFor:'accessing'!
thumbHeight
"redefined since a slider has no height - just origin"
^ nil
! !
!HorizontalSlider methodsFor:'private'!
absFromPercent:percent
"given a percentage, compute number of pixels"
^ ((percent * (width - sliderHeight - (margin * 2))) / 100) rounded
!
percentFromAbs:absValue
"given a number of pixels, compute percentage"
|val|
val := absValue / (width - 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.
nx := (self absFromPercent:thumbOrigin) + margin.
nw := sliderHeight.
ny := margin + inset.
nh := height - (2 * ny).
"
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
! !