author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 17:30:31 +0100 | |
changeset 86 | 4d7dbb5f1719 |
parent 49 | 4dd0f5c3353e |
child 1229 | a0a54048f8ee |
permissions | -rw-r--r-- |
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 |
||
49 | 13 |
SimpleView subclass:#Scale |
1 | 14 |
instanceVariableNames:'slider range action' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Interactors' |
|
18 |
! |
|
19 |
||
34 | 20 |
!Scale class methodsFor:'documentation'! |
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
version |
|
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
49
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libwidg2/Scale.st,v 1.4 1995-11-11 16:29:19 cg Exp $' |
34 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
like a slider, but with a range (i.e. may be different from 0..100) |
|
43 |
and displaying the current value. |
|
44 |
" |
|
45 |
! |
|
46 |
||
47 |
examples |
|
48 |
" |
|
49 |
|top s1 s2| |
|
50 |
||
51 |
top := StandardSystemView new. |
|
52 |
top extent:200@200. |
|
53 |
s1 := Scale origin:0.0 @ 0.0 extent:50 @ 1.0 in:top. |
|
54 |
s2 := Scale origin:0.5 @ 0.0 extent:50 @ 1.0 in:top. |
|
55 |
s2 range:(-50 to:50). |
|
56 |
top open |
|
57 |
" |
|
58 |
! ! |
|
59 |
||
1 | 60 |
!Scale methodsFor:'slider actions'! |
61 |
||
62 |
scroll:percent |
|
63 |
|value y label| |
|
64 |
||
65 |
action notNil ifTrue:[ |
|
34 | 66 |
value := (range last - range first) * (percent / 100). |
67 |
value := value + range first. |
|
68 |
action value:value. |
|
1 | 69 |
|
34 | 70 |
y := slider thumbFrame top + (slider thumbFrame height // 2). |
71 |
self clear. |
|
72 |
self paint:Black. |
|
73 |
value := value roundTo:(range last - range first) / 100. |
|
74 |
label := value asFloat printString. |
|
75 |
(label endsWith:'.0') ifTrue:[ |
|
76 |
label := value asInteger printString |
|
77 |
]. |
|
78 |
self displayString:label |
|
79 |
x:slider width + device horizontalPixelPerMillimeter |
|
80 |
y:y + (font ascent // 2) |
|
1 | 81 |
] |
82 |
! ! |
|
83 |
||
84 |
!Scale methodsFor:'accessing'! |
|
85 |
||
86 |
range:anInterval |
|
87 |
range := anInterval |
|
88 |
! |
|
89 |
||
90 |
scrollAction:aBlock |
|
91 |
action := aBlock |
|
92 |
! ! |
|
93 |
||
94 |
!Scale methodsFor:'initialization'! |
|
95 |
||
96 |
initialize |
|
97 |
super initialize. |
|
98 |
||
99 |
range := (0 to:100). |
|
100 |
slider := Slider in:self. |
|
34 | 101 |
slider fixSize. |
1 | 102 |
slider origin:0.0 @ 0.0. |
103 |
slider extent:slider width@ 1.0. |
|
104 |
self width:(slider width |
|
34 | 105 |
+ (font widthOf:'100') |
106 |
+ (device horizontalPixelPerMillimeter * 2) rounded). |
|
1 | 107 |
|
108 |
slider scrollAction:[:percent | self scroll:percent]. |
|
109 |
! ! |
|
110 |