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