author | Claus Gittinger <cg@exept.de> |
Thu, 07 Mar 2019 10:42:40 +0100 | |
changeset 6031 | 608583d9fea7 |
parent 3150 | e3a55f15ef7e |
child 4770 | 6634b540fea2 |
permissions | -rw-r--r-- |
333 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
3150 | 3 |
All Rights Reserved |
333 | 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' }" |
333 | 14 |
|
577 | 15 |
'From Smalltalk/X, Version:3.2.1 on 25-oct-1997 at 9:33:18 pm' ! |
16 |
||
333 | 17 |
ComboBoxView subclass:#ComboUpDownView |
18 |
instanceVariableNames:'minValue maxValue step currentValue values valueIndex' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Views-Interactors' |
|
22 |
! |
|
23 |
||
24 |
!ComboUpDownView class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
|
3150 | 29 |
All Rights Reserved |
333 | 30 |
|
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
||
39 |
||
40 |
! |
|
41 |
||
42 |
documentation |
|
43 |
" |
|
577 | 44 |
an up/down comboView (also called comboSpin). |
333 | 45 |
|
46 |
This is a quick&dirty hack, not yet finished and may change. |
|
47 |
||
48 |
[author:] |
|
3150 | 49 |
Claus Gittinger |
333 | 50 |
|
51 |
[see also:] |
|
3150 | 52 |
ComboListView ComboBoxView |
53 |
Slider |
|
333 | 54 |
" |
55 |
! |
|
56 |
||
57 |
examples |
|
58 |
" |
|
3150 | 59 |
non-MVC use; |
333 | 60 |
set min/max: |
3150 | 61 |
[exBegin] |
333 | 62 |
|top udBox| |
63 |
||
64 |
top := StandardSystemView new. |
|
65 |
top extent:(300 @ 200). |
|
66 |
||
67 |
udBox := ComboUpDownView in:top. |
|
68 |
udBox origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
69 |
udBox bottomInset:(udBox preferredExtent y negated). |
|
70 |
||
71 |
udBox minValue:1; maxValue:99; currentValue:10. |
|
72 |
top open. |
|
3150 | 73 |
[exEnd] |
333 | 74 |
set step: |
3150 | 75 |
[exBegin] |
333 | 76 |
|top udBox| |
77 |
||
78 |
top := StandardSystemView new. |
|
79 |
top extent:(300 @ 200). |
|
80 |
||
81 |
udBox := ComboUpDownView in:top. |
|
82 |
udBox origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
83 |
udBox bottomInset:(udBox preferredExtent y negated). |
|
84 |
||
85 |
udBox minValue:1; maxValue:99; step:10; currentValue:10. |
|
86 |
top open. |
|
3150 | 87 |
[exEnd] |
333 | 88 |
define a list of values: |
3150 | 89 |
[exBegin] |
333 | 90 |
|top udBox| |
91 |
||
92 |
top := StandardSystemView new. |
|
93 |
top extent:(300 @ 200). |
|
94 |
||
95 |
udBox := ComboUpDownView in:top. |
|
96 |
udBox origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
97 |
udBox bottomInset:(udBox preferredExtent y negated). |
|
98 |
||
99 |
udBox values:#('red' 'green' 'blue' 'black' 'white'); |
|
3150 | 100 |
valueIndex:1. |
333 | 101 |
top open. |
3150 | 102 |
[exEnd] |
333 | 103 |
" |
104 |
! ! |
|
105 |
||
106 |
!ComboUpDownView methodsFor:'accessing'! |
|
107 |
||
108 |
currentValue |
|
109 |
"return the value of the instance variable 'currentValue' (automatically generated)" |
|
110 |
||
111 |
^ currentValue |
|
112 |
||
113 |
"Created: 29.3.1997 / 11:47:06 / cg" |
|
114 |
! |
|
115 |
||
116 |
currentValue:something |
|
117 |
"set the value of the instance variable 'currentValue' (automatically generated)" |
|
118 |
||
119 |
currentValue := something. |
|
120 |
values notNil ifTrue:[ |
|
3150 | 121 |
valueIndex := values indexOf:currentValue |
333 | 122 |
]. |
123 |
field contents:currentValue printString. |
|
124 |
||
125 |
"Modified: 29.3.1997 / 11:49:48 / cg" |
|
126 |
! |
|
127 |
||
128 |
maxValue |
|
129 |
"return the value of the instance variable 'maxValue' (automatically generated)" |
|
130 |
||
131 |
^ maxValue |
|
132 |
||
133 |
"Created: 29.3.1997 / 11:45:29 / cg" |
|
134 |
! |
|
135 |
||
136 |
maxValue:something |
|
137 |
"set the value of the instance variable 'maxValue' (automatically generated)" |
|
138 |
||
139 |
maxValue := something. |
|
140 |
||
141 |
"Created: 29.3.1997 / 11:45:29 / cg" |
|
142 |
! |
|
143 |
||
144 |
minValue |
|
145 |
"return the value of the instance variable 'minValue' (automatically generated)" |
|
146 |
||
147 |
^ minValue |
|
148 |
||
149 |
"Created: 29.3.1997 / 11:45:27 / cg" |
|
150 |
! |
|
151 |
||
152 |
minValue:something |
|
153 |
"set the value of the instance variable 'minValue' (automatically generated)" |
|
154 |
||
155 |
minValue := something. |
|
156 |
||
157 |
"Created: 29.3.1997 / 11:45:27 / cg" |
|
158 |
! |
|
159 |
||
160 |
step |
|
161 |
"return the value of the instance variable 'step' (automatically generated)" |
|
162 |
||
163 |
^ step |
|
164 |
||
165 |
"Created: 29.3.1997 / 11:45:31 / cg" |
|
166 |
! |
|
167 |
||
168 |
step:something |
|
169 |
"set the value of the instance variable 'step' (automatically generated)" |
|
170 |
||
171 |
step := something. |
|
172 |
||
173 |
"Created: 29.3.1997 / 11:45:31 / cg" |
|
174 |
! |
|
175 |
||
176 |
valueIndex |
|
177 |
"return the value of the instance variable 'valueIndex' (automatically generated)" |
|
178 |
||
179 |
^ valueIndex |
|
180 |
||
181 |
"Created: 29.3.1997 / 11:45:37 / cg" |
|
182 |
! |
|
183 |
||
184 |
valueIndex:something |
|
185 |
"set the value of the instance variable 'valueIndex' (automatically generated)" |
|
186 |
||
187 |
valueIndex := something. |
|
188 |
values notNil ifTrue:[ |
|
3150 | 189 |
currentValue := values at:valueIndex. |
190 |
field contents:currentValue printString. |
|
333 | 191 |
]. |
192 |
||
193 |
"Created: 29.3.1997 / 11:45:38 / cg" |
|
194 |
"Modified: 29.3.1997 / 11:51:07 / cg" |
|
195 |
! |
|
196 |
||
197 |
values |
|
198 |
"return the value of the instance variable 'values' (automatically generated)" |
|
199 |
||
200 |
^ values |
|
201 |
||
202 |
"Created: 29.3.1997 / 11:45:34 / cg" |
|
203 |
! |
|
204 |
||
205 |
values:something |
|
206 |
"set the value of the instance variable 'values' (automatically generated)" |
|
207 |
||
208 |
values := something. |
|
209 |
||
210 |
"Created: 29.3.1997 / 11:45:34 / cg" |
|
211 |
! ! |
|
212 |
||
213 |
!ComboUpDownView methodsFor:'initialization'! |
|
214 |
||
215 |
initializeButton |
|
337
de0a0cb4275b
made u/d button a separate widget
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
216 |
|v| |
333 | 217 |
|
337
de0a0cb4275b
made u/d button a separate widget
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
218 |
v := UpDownButton in:self. |
de0a0cb4275b
made u/d button a separate widget
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
219 |
v upAction:[self countUp]. |
de0a0cb4275b
made u/d button a separate widget
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
220 |
v downAction:[self countDown]. |
333 | 221 |
|
222 |
pullDownButton := v. |
|
223 |
||
224 |
"Created: 29.3.1997 / 11:35:10 / cg" |
|
337
de0a0cb4275b
made u/d button a separate widget
Claus Gittinger <cg@exept.de>
parents:
333
diff
changeset
|
225 |
"Modified: 1.4.1997 / 12:00:51 / cg" |
333 | 226 |
! ! |
227 |
||
228 |
!ComboUpDownView methodsFor:'user interaction'! |
|
229 |
||
230 |
count:delta |
|
231 |
|newIndex newValue| |
|
232 |
||
233 |
values notNil ifTrue:[ |
|
3150 | 234 |
valueIndex notNil ifTrue:[ |
235 |
newIndex := valueIndex + delta. |
|
236 |
(newIndex between:1 and:values size) ifTrue:[ |
|
237 |
valueIndex := newIndex. |
|
333 | 238 |
|
3150 | 239 |
newValue := values at:valueIndex. |
240 |
]. |
|
241 |
]. |
|
333 | 242 |
] ifFalse:[ |
3150 | 243 |
currentValue notNil ifTrue:[ |
244 |
minValue notNil ifTrue:[ |
|
245 |
maxValue notNil ifTrue:[ |
|
246 |
step isNil ifTrue:[ |
|
247 |
newValue := currentValue + delta |
|
248 |
] ifFalse:[ |
|
249 |
newValue := currentValue + (delta * step) |
|
250 |
]. |
|
251 |
(newValue between:minValue and:maxValue) ifFalse:[ |
|
252 |
newValue := nil. |
|
253 |
] |
|
254 |
] |
|
255 |
] |
|
256 |
]. |
|
333 | 257 |
]. |
258 |
||
259 |
newValue notNil ifTrue:[ |
|
3150 | 260 |
currentValue := newValue. |
261 |
field contents:newValue printString. |
|
262 |
field accept. |
|
333 | 263 |
|
3150 | 264 |
action notNil ifTrue:[ |
265 |
action value:newValue |
|
266 |
]. |
|
333 | 267 |
] |
268 |
||
269 |
"Created: 29.3.1997 / 11:44:29 / cg" |
|
270 |
"Modified: 29.3.1997 / 11:46:58 / cg" |
|
271 |
! |
|
272 |
||
273 |
countDown |
|
274 |
self count:-1 |
|
275 |
||
276 |
"Created: 29.3.1997 / 11:39:17 / cg" |
|
277 |
! |
|
278 |
||
279 |
countUp |
|
280 |
self count:1 |
|
281 |
||
282 |
"Created: 29.3.1997 / 11:39:12 / cg" |
|
283 |
! ! |
|
284 |
||
285 |
!ComboUpDownView class methodsFor:'documentation'! |
|
286 |
||
287 |
version |
|
3150 | 288 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboUpDownView.st,v 1.5 2006-11-13 16:11:29 cg Exp $' |
333 | 289 |
! ! |