1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
34
|
3 |
All Rights Reserved
|
1
|
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 |
|
3150
|
13 |
"{ Package: 'stx:libwidg2' }"
|
|
14 |
|
49
|
15 |
SimpleView subclass:#HorizontalScale
|
1229
|
16 |
instanceVariableNames:'slider range action'
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Views-Interactors'
|
1
|
20 |
!
|
|
21 |
|
34
|
22 |
!HorizontalScale class methodsFor:'documentation'!
|
|
23 |
|
|
24 |
copyright
|
|
25 |
"
|
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
27 |
All Rights Reserved
|
|
28 |
|
|
29 |
This software is furnished under a license and may be used
|
|
30 |
only in accordance with the terms of that license and with the
|
|
31 |
inclusion of the above copyright notice. This software may not
|
|
32 |
be provided or otherwise made available to, or used by, any
|
|
33 |
other person. No title to or ownership of the software is
|
|
34 |
hereby transferred.
|
|
35 |
"
|
|
36 |
!
|
|
37 |
|
|
38 |
documentation
|
|
39 |
"
|
|
40 |
like a slider, but with a range (i.e. may be different from 0..100)
|
|
41 |
and displaying the current value.
|
|
42 |
"
|
1229
|
43 |
!
|
1
|
44 |
|
3150
|
45 |
examples
|
1229
|
46 |
"
|
|
47 |
|top s1 s2|
|
1
|
48 |
|
1229
|
49 |
top := StandardSystemView new.
|
|
50 |
top extent:200@200.
|
|
51 |
s1 := HorizontalScale origin:0.0 @ 0.0 in:top.
|
|
52 |
s1 extent:1.0 @ 50.
|
|
53 |
|
|
54 |
s2 := HorizontalScale origin:0.0 @ 0.5 in:top.
|
|
55 |
s2 extent:1.0 @ 50.
|
|
56 |
s2 range:(-50 to:50).
|
|
57 |
top open
|
|
58 |
"
|
|
59 |
|
1
|
60 |
! !
|
|
61 |
|
|
62 |
!HorizontalScale methodsFor:'accessing'!
|
|
63 |
|
|
64 |
range:anInterval
|
|
65 |
range := anInterval
|
|
66 |
!
|
|
67 |
|
|
68 |
scrollAction:aBlock
|
|
69 |
action := aBlock
|
|
70 |
! !
|
|
71 |
|
1229
|
72 |
!HorizontalScale methodsFor:'drawing'!
|
|
73 |
|
|
74 |
redraw
|
|
75 |
|percent value x label|
|
|
76 |
|
|
77 |
percent := slider thumbOrigin.
|
|
78 |
|
|
79 |
value := (range last - range first) * (percent / 100).
|
|
80 |
value := value + range first.
|
|
81 |
|
|
82 |
x := slider thumbFrame left + (slider thumbFrame width // 2).
|
|
83 |
self clear.
|
|
84 |
self paint:Black.
|
|
85 |
value := value roundTo:(range last - range first) / 100.
|
|
86 |
label := value asFloat printString.
|
|
87 |
(label endsWith:'.0') ifTrue:[
|
3150
|
88 |
label := value asInteger printString
|
1229
|
89 |
].
|
|
90 |
self displayString:label
|
3150
|
91 |
x:x - ((font widthOf:label) // 2)
|
|
92 |
y:font ascent + device verticalPixelPerMillimeter
|
1229
|
93 |
|
|
94 |
"Created: / 7.3.1999 / 00:16:54 / cg"
|
|
95 |
"Modified: / 7.3.1999 / 00:26:19 / cg"
|
|
96 |
! !
|
|
97 |
|
1
|
98 |
!HorizontalScale methodsFor:'initialization'!
|
|
99 |
|
|
100 |
initialize
|
|
101 |
super initialize.
|
|
102 |
|
|
103 |
range := (0 to:100).
|
|
104 |
slider := HorizontalSlider in:self.
|
|
105 |
slider origin:0.0 @ (font height + device verticalPixelPerMillimeter rounded).
|
1229
|
106 |
slider width:1.0.
|
|
107 |
|
3150
|
108 |
"/ self height:(slider height
|
1229
|
109 |
"/ + (font height)
|
|
110 |
"/ + (device verticalPixelPerMillimeter * 2) rounded).
|
1
|
111 |
|
|
112 |
slider scrollAction:[:percent | self scroll:percent].
|
1229
|
113 |
|
|
114 |
"Modified: / 7.3.1999 / 00:21:52 / cg"
|
1
|
115 |
! !
|
1229
|
116 |
|
|
117 |
!HorizontalScale methodsFor:'queries'!
|
|
118 |
|
|
119 |
preferredExtent
|
|
120 |
^ slider preferredExtent + (0 @ (font height + device verticalPixelPerMillimeter rounded))
|
|
121 |
|
|
122 |
"Created: / 7.3.1999 / 00:18:28 / cg"
|
|
123 |
"Modified: / 7.3.1999 / 00:24:40 / cg"
|
|
124 |
! !
|
|
125 |
|
|
126 |
!HorizontalScale methodsFor:'slider actions'!
|
|
127 |
|
|
128 |
scroll:percent
|
|
129 |
|value|
|
|
130 |
|
|
131 |
value := (range last - range first) * (percent / 100).
|
|
132 |
value := value + range first.
|
|
133 |
action notNil ifTrue:[
|
3150
|
134 |
action value:value.
|
1229
|
135 |
].
|
|
136 |
self redraw
|
|
137 |
|
|
138 |
"Modified: / 7.3.1999 / 00:17:33 / cg"
|
|
139 |
! !
|
|
140 |
|
|
141 |
!HorizontalScale class methodsFor:'documentation'!
|
|
142 |
|
|
143 |
version
|
3150
|
144 |
^ '$Header: /cvs/stx/stx/libwidg2/HorizontalScale.st,v 1.6 2006-11-13 16:11:30 cg Exp $'
|
1229
|
145 |
! !
|