17
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
24
|
3 |
All Rights Reserved
|
17
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
HorizontalScroller subclass:#HorizontalSlider
|
|
14 |
instanceVariableNames:'sliderHeight'
|
|
15 |
classVariableNames: ''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Interactors'
|
|
18 |
!
|
|
19 |
|
|
20 |
HorizontalSlider comment:'
|
|
21 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
24
|
22 |
All Rights Reserved
|
17
|
23 |
|
48
|
24 |
$Header: /cvs/stx/stx/libwidg2/HorizontalSlider.st,v 1.3 1995-04-30 13:40:33 claus Exp $
|
17
|
25 |
'!
|
|
26 |
|
|
27 |
!HorizontalSlider class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
24
|
32 |
All Rights Reserved
|
17
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
48
|
45 |
$Header: /cvs/stx/stx/libwidg2/HorizontalSlider.st,v 1.3 1995-04-30 13:40:33 claus Exp $
|
17
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
this class implements horizontal sliders.
|
|
52 |
"
|
|
53 |
! !
|
|
54 |
|
|
55 |
!HorizontalSlider methodsFor:'initialization'!
|
|
56 |
|
|
57 |
initialize
|
|
58 |
sliderHeight := (self verticalPixelPerMillimeter:10) rounded.
|
|
59 |
super initialize.
|
48
|
60 |
thumbHeight := 0.
|
17
|
61 |
!
|
|
62 |
|
|
63 |
initStyle
|
|
64 |
super initStyle.
|
24
|
65 |
tallyMarks := StyleSheet at:'sliderNTallyMarks' default:1.
|
|
66 |
tallyLevel := StyleSheet at:'sliderTallyLevel' default:-1.
|
17
|
67 |
! !
|
|
68 |
|
|
69 |
!HorizontalSlider methodsFor:'accessing'!
|
|
70 |
|
|
71 |
thumbHeight
|
|
72 |
"redefined since a slider has no height - just origin"
|
|
73 |
|
|
74 |
^ nil
|
|
75 |
! !
|
|
76 |
|
|
77 |
!HorizontalSlider methodsFor:'private'!
|
|
78 |
|
|
79 |
absFromPercent:percent
|
|
80 |
"given a percentage, compute number of pixels"
|
|
81 |
|
|
82 |
^ ((percent * (width - sliderHeight - (margin * 2))) / 100) rounded
|
|
83 |
!
|
|
84 |
|
|
85 |
percentFromAbs:absValue
|
|
86 |
"given a number of pixels, compute percentage"
|
|
87 |
|
|
88 |
|val|
|
|
89 |
|
|
90 |
val := absValue / (width - sliderHeight - (margin * 2)) * 100.
|
|
91 |
val < 0 ifTrue:[^ 0].
|
|
92 |
val > 100 ifTrue:[^ 100].
|
|
93 |
^ val
|
|
94 |
!
|
|
95 |
|
|
96 |
computeThumbFrame
|
|
97 |
"redefined, since the thumb-height stays constant"
|
|
98 |
|
|
99 |
|nh nw ny nx|
|
|
100 |
|
|
101 |
thumbHeight := 0.
|
|
102 |
nx := (self absFromPercent:thumbOrigin) + margin.
|
|
103 |
nw := sliderHeight.
|
|
104 |
ny := margin + inset.
|
|
105 |
nh := height - (2 * ny).
|
|
106 |
"
|
|
107 |
do not create new Rectangle if its the same anyway
|
|
108 |
"
|
|
109 |
thumbFrame notNil ifTrue:[
|
24
|
110 |
(ny == thumbFrame top) ifTrue:[
|
|
111 |
(nx == thumbFrame left) ifTrue:[
|
|
112 |
(nh == thumbFrame height) ifTrue:[
|
|
113 |
(nw == thumbFrame width) ifTrue:[ ^ self]
|
|
114 |
]
|
|
115 |
]
|
|
116 |
]
|
17
|
117 |
].
|
|
118 |
thumbFrame := Rectangle left:nx top:ny width:nw height:nh
|
|
119 |
! !
|