"
COPYRIGHT (c) 1993 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.
"
SimpleView subclass:#HorizontalScale
instanceVariableNames:'slider range action'
classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
!
!HorizontalScale class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1993 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/HorizontalScale.st,v 1.4 1995-11-11 16:28:57 cg Exp $'
!
documentation
"
like a slider, but with a range (i.e. may be different from 0..100)
and displaying the current value.
"
! !
!HorizontalScale methodsFor:'slider actions'!
scroll:percent
|value x label|
action notNil ifTrue:[
value := (range last - range first) * (percent / 100).
value := value + range first.
action value:value.
x := slider thumbFrame left + (slider thumbFrame width // 2).
self clear.
self paint:Black.
value := value roundTo:(range last - range first) / 100.
label := value asFloat printString.
(label endsWith:'.0') ifTrue:[
label := value asInteger printString
].
self displayString:label
x:x + ((font widthOf:label) // 2)
y:slider height + device verticalPixelPerMillimeter
]
! !
!HorizontalScale methodsFor:'accessing'!
range:anInterval
range := anInterval
!
scrollAction:aBlock
action := aBlock
! !
!HorizontalScale methodsFor:'initialization'!
initialize
super initialize.
range := (0 to:100).
slider := HorizontalSlider in:self.
slider origin:0.0 @ (font height + device verticalPixelPerMillimeter rounded).
slider extent:1.0 @ slider height.
self height:(slider height
+ (font height)
+ (device verticalPixelPerMillimeter * 2) rounded).
slider scrollAction:[:percent | self scroll:percent].
! !