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