author | Claus Gittinger <cg@exept.de> |
Fri, 09 Feb 1996 02:42:03 +0100 | |
changeset 125 | db1c1a8e0384 |
parent 86 | 4d7dbb5f1719 |
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:#HorizontalScale |
34 | 14 |
instanceVariableNames:'slider range action' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Interactors' |
|
1 | 18 |
! |
19 |
||
34 | 20 |
!HorizontalScale 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/Attic/HScale.st,v 1.4 1995-11-11 16:28:57 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 |
||
1 | 47 |
!HorizontalScale methodsFor:'slider actions'! |
48 |
||
49 |
scroll:percent |
|
50 |
|value x label| |
|
51 |
||
52 |
action notNil ifTrue:[ |
|
34 | 53 |
value := (range last - range first) * (percent / 100). |
54 |
value := value + range first. |
|
55 |
action value:value. |
|
1 | 56 |
|
34 | 57 |
x := slider thumbFrame left + (slider thumbFrame width // 2). |
58 |
self clear. |
|
59 |
self paint:Black. |
|
60 |
value := value roundTo:(range last - range first) / 100. |
|
61 |
label := value asFloat printString. |
|
62 |
(label endsWith:'.0') ifTrue:[ |
|
63 |
label := value asInteger printString |
|
64 |
]. |
|
65 |
self displayString:label |
|
66 |
x:x + ((font widthOf:label) // 2) |
|
67 |
y:slider height + device verticalPixelPerMillimeter |
|
1 | 68 |
] |
69 |
! ! |
|
70 |
||
71 |
!HorizontalScale methodsFor:'accessing'! |
|
72 |
||
73 |
range:anInterval |
|
74 |
range := anInterval |
|
75 |
! |
|
76 |
||
77 |
scrollAction:aBlock |
|
78 |
action := aBlock |
|
79 |
! ! |
|
80 |
||
81 |
!HorizontalScale methodsFor:'initialization'! |
|
82 |
||
83 |
initialize |
|
84 |
super initialize. |
|
85 |
||
86 |
range := (0 to:100). |
|
87 |
slider := HorizontalSlider in:self. |
|
88 |
slider origin:0.0 @ (font height + device verticalPixelPerMillimeter rounded). |
|
89 |
slider extent:1.0 @ slider height. |
|
90 |
self height:(slider height |
|
34 | 91 |
+ (font height) |
92 |
+ (device verticalPixelPerMillimeter * 2) rounded). |
|
1 | 93 |
|
94 |
slider scrollAction:[:percent | self scroll:percent]. |
|
95 |
! ! |