author | Claus Gittinger <cg@exept.de> |
Sat, 11 May 2019 12:15:03 +0200 | |
changeset 6578 | 60be865bd75a |
parent 6499 | 82f16794a274 |
child 6651 | 226b0380aadf |
permissions | -rw-r--r-- |
6468 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1991 by Claus Gittinger |
59 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
2212
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
14 |
"{ Package: 'stx:libwidg' }" |
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
15 |
|
5893 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
18 |
DialogBox subclass:#OptionBox |
6468 | 19 |
instanceVariableNames:'labelPanel formLabel textLabel textView buttons actions |
20 |
defaultButtonIndex' |
|
6235 | 21 |
classVariableNames:'WarnBitmap InfoBitmap YesNoBitmap' |
355 | 22 |
poolDictionaries:'' |
23 |
category:'Views-DialogBoxes' |
|
0 | 24 |
! |
25 |
||
847 | 26 |
!OptionBox class methodsFor:'documentation'! |
7 | 27 |
|
38 | 28 |
copyright |
29 |
" |
|
30 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
59 | 31 |
All Rights Reserved |
38 | 32 |
|
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
! |
|
41 |
||
7 | 42 |
documentation |
43 |
" |
|
646 | 44 |
CAVEAT: this is a leftover - functionality has been merged into DialogBox |
3936 | 45 |
PLEASE use one of the `Dialog chooseXXX' methods instead of OptionBox. |
646 | 46 |
|
47 |
||
355 | 48 |
Historic note: |
646 | 49 |
originally, ST/X had separate classes for the various entry methods; |
50 |
there were YesNoBox, EnterBox, InfoBox and so on. |
|
51 |
In the meantime, the DialogBox class (and therefore its alias: Dialog) |
|
5893 | 52 |
is going to duplicate most functionality found in these classes. |
355 | 53 |
|
646 | 54 |
In the future, those existing subclasses' functionality is going to |
55 |
be moved fully into Dialog, and the subclasses will be replaced by dummy |
|
56 |
delegators. (They will be kept for backward compatibility, though). |
|
355 | 57 |
|
6468 | 58 |
Description: |
59 |
OptionBoxes are like YesNoBoxes but with as many buttons as you like; |
|
60 |
this will finally be a superclass of WarnBox and YesNoBox - or maybe merged |
|
61 |
all into DialogBox.. |
|
62 |
Use them for multiway questions. |
|
63 |
For a consistent user interface, the rightmost (last) button should be the default return |
|
64 |
button (i.e. pressing return in the box performs this buttons function). |
|
65 |
However, this is reversed automatically if the viewStyle says so (Windows vs. OSX vs. Linux), |
|
66 |
so the programmer MUST always put the no-actions (i.e. cancel) first and the ok-actions (yes) last. |
|
91 | 67 |
|
646 | 68 |
[author:] |
69 |
Claus Gittinger |
|
91 | 70 |
|
646 | 71 |
[see also:] |
72 |
DialogBox |
|
73 |
" |
|
74 |
! |
|
91 | 75 |
|
646 | 76 |
examples |
77 |
" |
|
6468 | 78 |
just opening |
79 |
(not real world examples, as you'd have to ask the box instance about the choice afterwards; |
|
80 |
see better usage examples below): |
|
646 | 81 |
[exBegin] |
82 |
|box| |
|
97 | 83 |
|
646 | 84 |
box := OptionBox title:'hello' numberOfOptions:4. |
85 |
box showAtPointer |
|
86 |
[exEnd] |
|
97 | 87 |
|
88 |
||
646 | 89 |
[exBegin] |
90 |
|box| |
|
6468 | 91 |
box := OptionBox title:'hello'. |
646 | 92 |
box buttonTitles:#('one' 'two' 'three'). |
6468 | 93 |
box defaultButtonIndex:3. |
94 |
box showAtPointer |
|
95 |
[exEnd] |
|
96 |
||
97 |
showing a long list: |
|
98 |
[exBegin] |
|
99 |
|box| |
|
100 |
box := OptionBox title:(1 to:100 collect:#asString) numberOfOptions:3. |
|
101 |
box buttonTitles:#('one' 'two' 'three'). |
|
102 |
box defaultButtonIndex:3. |
|
646 | 103 |
box showAtPointer |
104 |
[exEnd] |
|
97 | 105 |
|
646 | 106 |
performing an action: |
97 | 107 |
|
646 | 108 |
[exBegin] |
109 |
|box| |
|
110 |
box := OptionBox title:'hello' numberOfOptions:3. |
|
111 |
box buttonTitles:#('one' 'two' 'three'). |
|
112 |
box action:[:which | Transcript show:'button '; |
|
113 |
show: which; |
|
655 | 114 |
showCR:' was pressed']. |
646 | 115 |
box showAtPointer |
116 |
[exEnd] |
|
97 | 117 |
|
646 | 118 |
returning a value: |
119 |
[exBegin] |
|
120 |
|what| |
|
133 | 121 |
|
5893 | 122 |
what := OptionBox |
646 | 123 |
request:('text has not been accepted.\\Your modifications will be lost when continuing.') withCRs |
124 |
label:' Attention' |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
125 |
image:(WarningBox iconBitmap) |
3211 | 126 |
buttonLabels:#('Abort' 'Accept' 'Continue') |
646 | 127 |
values:#(#abort #accept #continue). |
655 | 128 |
Transcript showCR:what. |
646 | 129 |
[exEnd] |
3211 | 130 |
|
131 |
||
132 |
use callBack-hook to intercept creation: |
|
133 |
[exBegin] |
|
134 |
|what| |
|
135 |
||
136 |
AboutToOpenBoxNotificationSignal handle:[:ex | |
|
137 |
|box| |
|
138 |
||
139 |
box := ex parameter. |
|
5893 | 140 |
box verticalPanel |
3211 | 141 |
add:(CheckBox label:'Do no show this Dialog again.' |
142 |
model:false asValue). |
|
143 |
ex proceed. |
|
144 |
] do:[ |
|
5893 | 145 |
what := OptionBox |
3211 | 146 |
request:('bla bla bla bla.\\You must bla bla bla!!') withCRs |
147 |
label:' Attention' |
|
148 |
image:(WarningBox iconBitmap) |
|
149 |
buttonLabels:#('Abort' 'Accept' 'Continue') |
|
150 |
values:#(#abort #accept #continue) |
|
151 |
default:#continue. |
|
152 |
]. |
|
153 |
Transcript showCR:what. |
|
154 |
[exEnd] |
|
7 | 155 |
" |
197 | 156 |
! ! |
157 |
||
847 | 158 |
!OptionBox class methodsFor:'instance creation'! |
197 | 159 |
|
6468 | 160 |
title:titleString |
161 |
"create a new optionBox with title, aTitleString" |
|
162 |
||
163 |
|box| |
|
164 |
||
165 |
box := self basicNew. |
|
166 |
box device:Screen current. |
|
167 |
box initialize. |
|
168 |
box title:titleString. |
|
169 |
^ box |
|
170 |
||
171 |
"Created: / 26-10-2018 / 10:56:42 / Claus Gittinger" |
|
172 |
! |
|
173 |
||
197 | 174 |
title:titleString numberOfOptions:nOptions |
175 |
"create a new optionBox with title, aTitleString and nOptions options" |
|
176 |
||
177 |
|box| |
|
178 |
||
5027 | 179 |
box := self basicNew numberOfOptions:nOptions. |
197 | 180 |
box device:Screen current. |
181 |
box initialize. |
|
182 |
box title:titleString. |
|
183 |
^ box |
|
6468 | 184 |
|
185 |
"Modified (comment): / 26-10-2018 / 10:56:48 / Claus Gittinger" |
|
7 | 186 |
! ! |
187 |
||
2449 | 188 |
!OptionBox class methodsFor:'easy startup'! |
95 | 189 |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
190 |
forRequest:title label:label image:anImage buttonLabels:labels values:values default:defaultValue |
2585 | 191 |
"create a new optionBox and return it. |
192 |
Does not open the box." |
|
193 |
||
194 |
|box| |
|
195 |
||
196 |
box := OptionBox title:title numberOfOptions:(labels size). |
|
197 |
box buttonTitles:labels. |
|
5893 | 198 |
box defaultButtonIndex:(values indexOf:defaultValue). |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
199 |
box label:label; image:anImage. |
2898 | 200 |
values keysAndValuesDo:[:idx :val | |
201 |
val == false ifTrue:[ |
|
202 |
(box buttons at:idx) cursor:(Cursor thumbsDown). |
|
203 |
]. |
|
204 |
val == true ifTrue:[ |
|
205 |
(box buttons at:idx) cursor:(Cursor thumbsUp). |
|
206 |
]. |
|
207 |
]. |
|
2585 | 208 |
^ box |
209 |
||
210 |
"Modified: / 23.2.2000 / 11:59:32 / cg" |
|
211 |
! |
|
212 |
||
5893 | 213 |
request:title buttonLabels:labels values:values |
2668 | 214 |
"create a new optionBox, open it modal and return the value of |
6196 | 215 |
the corresponding values collection. Return nil if canceled" |
2668 | 216 |
|
5893 | 217 |
^ self |
218 |
request:title |
|
219 |
label:title |
|
220 |
buttonLabels:labels |
|
4223 | 221 |
values:values |
2668 | 222 |
|
223 |
" |
|
5893 | 224 |
OptionBox |
2668 | 225 |
request:'please select any' |
226 |
buttonLabels:#('one' 'two' 'three') |
|
5893 | 227 |
values:#(1 2 3) |
2668 | 228 |
" |
4223 | 229 |
|
230 |
"Modified: / 08-02-2011 / 11:22:13 / cg" |
|
6196 | 231 |
"Modified (comment): / 24-08-2017 / 15:03:02 / cg" |
2668 | 232 |
! |
233 |
||
2669 | 234 |
request:title buttonLabels:labels values:values default:defaultValue |
235 |
"create a new optionBox, open it modal and return the value of |
|
6196 | 236 |
the corresponding values collection. Return nil if canceled." |
2669 | 237 |
|
238 |
^ self |
|
5893 | 239 |
request:title label:title image:(YesNoBox iconBitmap) buttonLabels:labels values:values |
2711
e18e9edca978
by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents:
2700
diff
changeset
|
240 |
default:defaultValue onCancel:nil |
2669 | 241 |
|
242 |
" |
|
5893 | 243 |
OptionBox |
2669 | 244 |
request:'please select' |
245 |
buttonLabels:#('one' 'two' 'three') |
|
5893 | 246 |
values:#(1 2 3) |
247 |
default:3 |
|
2669 | 248 |
" |
6196 | 249 |
|
250 |
"Modified (comment): / 24-08-2017 / 15:03:07 / cg" |
|
2669 | 251 |
! |
252 |
||
5893 | 253 |
request:title label:label buttonLabels:labels values:values |
2405 | 254 |
"create a new optionBox, open it modal and return the value of |
6196 | 255 |
the corresponding values collection. Return nil if canceled" |
2405 | 256 |
|
5893 | 257 |
^ self |
258 |
request:title |
|
259 |
label:label |
|
4224 | 260 |
image:(YesNoBox iconBitmap) |
5893 | 261 |
buttonLabels:labels |
262 |
values:values |
|
263 |
default:nil |
|
4224 | 264 |
onCancel:nil |
2668 | 265 |
|
266 |
" |
|
5893 | 267 |
OptionBox |
2668 | 268 |
request:'please select' |
269 |
label:'select any' |
|
270 |
buttonLabels:#('one' 'two' 'three') |
|
5893 | 271 |
values:#(1 2 3) |
2668 | 272 |
" |
4224 | 273 |
|
274 |
"Modified: / 08-02-2011 / 11:32:48 / cg" |
|
6196 | 275 |
"Modified (comment): / 24-08-2017 / 15:03:10 / cg" |
2405 | 276 |
! |
277 |
||
278 |
request:title label:label buttonLabels:labels values:values default:defaultValue |
|
279 |
"create a new optionBox, open it modal and return the value of |
|
6196 | 280 |
the corresponding values collection. Return nil if canceled" |
2405 | 281 |
|
282 |
^ self |
|
5893 | 283 |
request:title label:label image:(YesNoBox iconBitmap) buttonLabels:labels values:values |
2711
e18e9edca978
by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents:
2700
diff
changeset
|
284 |
default:defaultValue onCancel:nil |
2668 | 285 |
|
286 |
" |
|
5893 | 287 |
OptionBox |
2668 | 288 |
request:'please select' |
289 |
label:'select any' |
|
290 |
buttonLabels:#('one' 'two' 'three') |
|
5893 | 291 |
values:#(1 2 3) |
292 |
default:3 |
|
2668 | 293 |
" |
6196 | 294 |
|
295 |
"Modified (comment): / 24-08-2017 / 15:03:15 / cg" |
|
2405 | 296 |
! |
297 |
||
298 |
request:title label:label buttonLabels:labels values:values default:defaultValue onCancel:cancelValue |
|
299 |
"create a new optionBox, open it modal and return the value of |
|
6196 | 300 |
the corresponding values collection. Return cancelValue if canceled." |
2405 | 301 |
|
302 |
^ self |
|
5893 | 303 |
request:title label:label image:(YesNoBox iconBitmap) buttonLabels:labels values:values |
2405 | 304 |
default:defaultValue onCancel:cancelValue |
2668 | 305 |
|
306 |
" |
|
5893 | 307 |
OptionBox |
2668 | 308 |
request:'please select' |
309 |
label:'select any' |
|
310 |
buttonLabels:#('one' 'two' 'three') |
|
5893 | 311 |
values:#(1 2 3) |
312 |
default:3 |
|
313 |
onCancel:2 |
|
2668 | 314 |
" |
6196 | 315 |
|
316 |
"Modified (comment): / 24-08-2017 / 15:03:18 / cg" |
|
2405 | 317 |
! |
318 |
||
5893 | 319 |
request:title label:label image:anImage buttonLabels:labels values:values |
133 | 320 |
"create a new optionBox, open it modal and return the value of |
6196 | 321 |
the corresponding values collection. Return nil, if canceled." |
133 | 322 |
|
5893 | 323 |
^ self |
324 |
request:title label:label image:anImage buttonLabels:labels values:values |
|
2711
e18e9edca978
by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents:
2700
diff
changeset
|
325 |
default:nil onCancel:nil |
2668 | 326 |
|
327 |
" |
|
5893 | 328 |
OptionBox |
2668 | 329 |
request:'please select' |
330 |
label:'select any' |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
331 |
image:(WarningBox iconBitmap) |
2668 | 332 |
buttonLabels:#('one' 'two' 'three') |
333 |
values:#(1 2 3) |
|
334 |
" |
|
6196 | 335 |
|
336 |
"Modified (comment): / 24-08-2017 / 15:03:31 / cg" |
|
133 | 337 |
! |
338 |
||
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
339 |
request:title label:label image:anImage buttonLabels:labels values:values default:defaultValue |
95 | 340 |
"create a new optionBox, open it modal and return the value of |
6196 | 341 |
the corresponding values collection. Return nil if canceled." |
95 | 342 |
|
2390 | 343 |
^ self |
5893 | 344 |
request:title label:label image:anImage buttonLabels:labels values:values |
2711
e18e9edca978
by default, return nil if cancelled
Claus Gittinger <cg@exept.de>
parents:
2700
diff
changeset
|
345 |
default:defaultValue onCancel:nil |
2668 | 346 |
|
347 |
" |
|
5893 | 348 |
OptionBox |
2668 | 349 |
request:'please select' |
350 |
label:'select any' |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
351 |
image:(WarningBox iconBitmap) |
2668 | 352 |
buttonLabels:#('one' 'two' 'three') |
353 |
values:#(1 2 3) |
|
354 |
default:3 |
|
355 |
" |
|
6196 | 356 |
|
357 |
"Modified (comment): / 24-08-2017 / 15:03:34 / cg" |
|
2390 | 358 |
! |
359 |
||
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
360 |
request:title label:label image:anImage buttonLabels:labels values:values default:defaultValue onCancel:cancelValue |
2390 | 361 |
"create a new optionBox, open it modal and return the value of |
6196 | 362 |
the corresponding values collection. Return cancelValue if canceled." |
2390 | 363 |
|
2162 | 364 |
|box retVal| |
95 | 365 |
|
2390 | 366 |
retVal := cancelValue. |
2585 | 367 |
box := self |
5893 | 368 |
forRequest:title |
369 |
label:label |
|
370 |
image:anImage |
|
371 |
buttonLabels:labels |
|
372 |
values:values |
|
2585 | 373 |
default:defaultValue. |
374 |
||
2162 | 375 |
box action:[:n | retVal := values at:n]. |
3211 | 376 |
self showAndThenDestroyBox:box. |
2389 | 377 |
|
2162 | 378 |
^ retVal |
95 | 379 |
|
380 |
" |
|
5893 | 381 |
OptionBox |
2668 | 382 |
request:'please select' |
383 |
label:'select any' |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
384 |
image:(WarningBox iconBitmap) |
2668 | 385 |
buttonLabels:#('one' 'two' 'three') |
386 |
values:#(1 2 3) |
|
387 |
default:3 |
|
388 |
onCancel:nil |
|
95 | 389 |
" |
920 | 390 |
|
6196 | 391 |
"Modified: / 23-02-2000 / 11:59:32 / cg" |
392 |
"Modified (comment): / 24-08-2017 / 15:03:36 / cg" |
|
95 | 393 |
! ! |
394 |
||
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
395 |
!OptionBox class methodsFor:'obsolete'! |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
396 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
397 |
forRequest:title label:label form:anImage buttonLabels:labels values:values default:defaultValue |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
398 |
"create a new optionBox and return it. |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
399 |
Does not open the box." |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
400 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
401 |
<resource:#obsolete> |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
402 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
403 |
self forRequest:title label:label image:anImage buttonLabels:labels values:values default:defaultValue |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
404 |
! |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
405 |
|
5893 | 406 |
request:title label:label form:aForm buttonLabels:labels values:values |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
407 |
"create a new optionBox, open it modal and return the value of |
6196 | 408 |
the corresponding values collection. Return nil, if canceled." |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
409 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
410 |
<resource:#obsolete> |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
411 |
|
5893 | 412 |
^ self |
413 |
request:title label:label image:aForm buttonLabels:labels values:values |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
414 |
default:nil onCancel:nil |
6196 | 415 |
|
416 |
"Modified (comment): / 24-08-2017 / 15:03:22 / cg" |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
417 |
! |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
418 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
419 |
request:title label:label form:aForm buttonLabels:labels values:values default:defaultValue |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
420 |
"create a new optionBox, open it modal and return the value of |
6196 | 421 |
the corresponding values collection. Return nil if canceled." |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
422 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
423 |
<resource:#obsolete> |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
424 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
425 |
^ self |
5893 | 426 |
request:title |
427 |
label:label |
|
428 |
image:aForm |
|
429 |
buttonLabels:labels |
|
430 |
values:values |
|
431 |
default:defaultValue |
|
2991 | 432 |
onCancel:nil |
6196 | 433 |
|
434 |
"Modified (comment): / 24-08-2017 / 15:03:25 / cg" |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
435 |
! |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
436 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
437 |
request:title label:label form:aForm buttonLabels:labels values:values default:defaultValue onCancel:cancelValue |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
438 |
"create a new optionBox, open it modal and return the value of |
6196 | 439 |
the corresponding values collection. Return cancelValue if canceled." |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
440 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
441 |
<resource:#obsolete> |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
442 |
|
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
443 |
^ self request:title label:label image:aForm buttonLabels:labels values:values default:defaultValue onCancel:cancelValue |
6196 | 444 |
|
445 |
"Modified (comment): / 24-08-2017 / 15:03:28 / cg" |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
446 |
! ! |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
447 |
|
197 | 448 |
!OptionBox methodsFor:'accessing'! |
449 |
||
450 |
action:actionBlock |
|
451 |
"define a single the action for all buttons. |
|
452 |
The action will be evaluated with the button index as argument." |
|
453 |
||
454 |
buttons keysAndValuesDo:[:index :button | |
|
455 |
button action:[ |
|
456 |
button turnOffWithoutRedraw. |
|
457 |
self hide. |
|
458 |
actionBlock value:index |
|
459 |
] |
|
460 |
]. |
|
461 |
! |
|
462 |
||
463 |
actions:actionBlocks |
|
464 |
"define the actions" |
|
0 | 465 |
|
197 | 466 |
actions := actionBlocks |
467 |
! |
|
468 |
||
469 |
buttonTitles:titles actions:actionBlocks |
|
470 |
"define both button titles and actions" |
|
471 |
||
472 |
self buttonTitles:titles. |
|
473 |
actions := actionBlocks. |
|
474 |
! |
|
0 | 475 |
|
197 | 476 |
defaultButtonIndex:index |
847 | 477 |
"define which button is the default (i.e. return-) button. |
6468 | 478 |
By default, no returnButton is setup. |
479 |
The argument must be an index 1..nButtons, or nil" |
|
847 | 480 |
|
197 | 481 |
defaultButtonIndex notNil ifTrue:[ |
847 | 482 |
(buttons at:defaultButtonIndex) isReturnButton:false |
197 | 483 |
]. |
484 |
(index notNil and:[index ~~ 0]) ifTrue:[ |
|
847 | 485 |
defaultButtonIndex := index. |
486 |
defaultButtonIndex notNil ifTrue:[ |
|
5893 | 487 |
(buttons at:defaultButtonIndex) isReturnButton:true |
847 | 488 |
]. |
197 | 489 |
] |
847 | 490 |
|
6468 | 491 |
"Modified: / 18-10-1996 / 14:53:36 / cg" |
492 |
"Modified (comment): / 26-10-2018 / 10:53:10 / Claus Gittinger" |
|
197 | 493 |
! |
494 |
||
495 |
numberOfOptions |
|
496 |
"return the number of options" |
|
497 |
||
498 |
^ buttons size |
|
499 |
! |
|
500 |
||
501 |
numberOfOptions:nOptions |
|
847 | 502 |
"set the number of options - this is a private interface" |
197 | 503 |
|
5109 | 504 |
buttons := OrderedCollection newWithSize:nOptions. |
505 |
actions := OrderedCollection newWithSize:nOptions |
|
847 | 506 |
|
507 |
"Modified: 18.10.1996 / 14:54:30 / cg" |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
508 |
! ! |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
509 |
|
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
510 |
!OptionBox methodsFor:'accessing-components'! |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
511 |
|
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
512 |
buttons |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
513 |
"return the buttons collection" |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
514 |
|
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
515 |
^ buttons |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
516 |
! |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
517 |
|
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
518 |
labelPanel |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
519 |
^ labelPanel |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
520 |
! ! |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
521 |
|
2227 | 522 |
!OptionBox methodsFor:'accessing-look'! |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
523 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
524 |
buttonTitles:titles |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
525 |
"set the button titles" |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
526 |
|
6468 | 527 |
buttons isNil ifTrue:[ self numberOfOptions:titles size; initializeButtons ]. |
528 |
||
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
529 |
titles keysAndValuesDo:[:index :aString | |
3733 | 530 |
|b| |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
531 |
|
3733 | 532 |
(b := buttons at:index) label:aString. |
533 |
b name: (b name? ''), index printString. |
|
534 |
b resize. |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
535 |
]. |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
536 |
shown ifTrue:[self resize] |
6468 | 537 |
|
538 |
"Modified: / 26-10-2018 / 11:02:48 / Claus Gittinger" |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
539 |
! |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
540 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
541 |
form:aFormOrImage |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
542 |
"historical leftover - define a form to be displayed left of the title" |
2212
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
543 |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
544 |
<resource:#obsolete> |
2212
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
545 |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
546 |
self image:aFormOrImage |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
547 |
! |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
548 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
549 |
formLabel |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
550 |
"return the label-view which displays a bitmap" |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
551 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
552 |
^ formLabel |
197 | 553 |
! |
0 | 554 |
|
2476 | 555 |
image:aFormOrImage |
556 |
"set the image shown in the label-view" |
|
557 |
||
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
558 |
|mm| |
2476 | 559 |
|
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
560 |
mm := ViewSpacing. |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
561 |
formLabel label:aFormOrImage. |
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
562 |
textLabel origin:((mm + formLabel width + mm) @ mm). |
2476 | 563 |
! |
564 |
||
2328 | 565 |
textLabel |
566 |
"return the label-view which displays a message string" |
|
567 |
||
568 |
^ textLabel |
|
569 |
! |
|
570 |
||
6468 | 571 |
title:aStringOrStringCollection |
16 | 572 |
"set the boxes title" |
0 | 573 |
|
6468 | 574 |
|textShown lines| |
575 |
||
576 |
aStringOrStringCollection isString ifTrue:[ |
|
577 |
textShown := aStringOrStringCollection withoutSeparators. |
|
578 |
] ifFalse:[ |
|
579 |
textShown := aStringOrStringCollection asStringCollection. |
|
580 |
]. |
|
581 |
textShown ~= textLabel label ifTrue:[ |
|
582 |
(lines := textShown asStringCollection) size > 25 ifTrue:[ |
|
583 |
verticalPanel verticalLayout:#topFit. |
|
584 |
textLabel label:''. |
|
585 |
labelPanel height:(labelPanel preferredHeight). |
|
586 |
textView beVisible. |
|
587 |
textLabel beInvisible. |
|
588 |
textView contents:lines. |
|
589 |
] ifFalse:[ |
|
590 |
textView beInvisible. |
|
591 |
textLabel beVisible. |
|
592 |
textLabel label:textShown. |
|
593 |
textLabel forceResize. |
|
594 |
]. |
|
595 |
shown ifTrue:[self resize] |
|
16 | 596 |
] |
6468 | 597 |
|
598 |
"Modified: / 26-10-2018 / 10:46:16 / Claus Gittinger" |
|
0 | 599 |
! |
600 |
||
97 | 601 |
title:aString numberOfOptions:nOptions |
602 |
"set the boxes title and number of options" |
|
603 |
||
604 |
self title:aString. |
|
605 |
buttons grow:nOptions. |
|
606 |
actions grow:nOptions |
|
197 | 607 |
! ! |
97 | 608 |
|
197 | 609 |
!OptionBox methodsFor:'events'! |
77 | 610 |
|
197 | 611 |
keyPress:aKey x:x y:y |
2700 | 612 |
"return-key duplicates ok-function if acceptReturnAsOK is true" |
77 | 613 |
|
4490 | 614 |
"/ <resource: #keyboard (#Return)> |
490 | 615 |
|
3804
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
616 |
"/ now done by keyboard processor |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
617 |
"/ |action| |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
618 |
"/ |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
619 |
"/ defaultButtonIndex notNil ifTrue:[ |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
620 |
"/ (aKey == #Return) ifTrue:[ |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
621 |
"/ self hide. |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
622 |
"/ action := actions at:defaultButtonIndex. |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
623 |
"/ action value |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
624 |
"/ ] |
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
625 |
"/ ]. |
197 | 626 |
super keyPress:aKey x:x y:y |
490 | 627 |
|
628 |
"Modified: 7.3.1996 / 13:17:36 / cg" |
|
197 | 629 |
! ! |
0 | 630 |
|
2523 | 631 |
!OptionBox methodsFor:'initialization'! |
7 | 632 |
|
197 | 633 |
initFormBitmap |
6235 | 634 |
self initYesNoBitmap |
635 |
||
636 |
"Modified: / 28-11-2017 / 14:33:16 / cg" |
|
637 |
! |
|
638 |
||
639 |
initInfoBitmap |
|
640 |
InfoBitmap isNil ifTrue:[ |
|
641 |
InfoBitmap := InfoBox iconBitmap. |
|
642 |
]. |
|
643 |
formLabel label:InfoBitmap |
|
644 |
||
645 |
"Created: / 28-11-2017 / 14:31:51 / cg" |
|
646 |
! |
|
647 |
||
648 |
initWarnBitmap |
|
197 | 649 |
WarnBitmap isNil ifTrue:[ |
1914 | 650 |
WarnBitmap := WarningBox iconBitmap. |
5893 | 651 |
"/ WarnBitmap := Image fromFile:'bitmaps/Warning.xbm' resolution:100 on:Display |
0 | 652 |
]. |
2969
eb87f1aedd6c
Do not use obsolete methods with #form:
Stefan Vogel <sv@exept.de>
parents:
2898
diff
changeset
|
653 |
formLabel label:WarnBitmap |
899 | 654 |
|
6235 | 655 |
"Created: / 28-11-2017 / 14:31:31 / cg" |
656 |
! |
|
657 |
||
658 |
initYesNoBitmap |
|
659 |
YesNoBitmap isNil ifTrue:[ |
|
660 |
YesNoBitmap := YesNoBox iconBitmap. |
|
661 |
]. |
|
662 |
formLabel label:YesNoBitmap |
|
663 |
||
664 |
"Created: / 28-11-2017 / 14:32:45 / cg" |
|
0 | 665 |
! |
666 |
||
667 |
initialize |
|
4383 | 668 |
|mm vPanelLayout| |
0 | 669 |
|
670 |
super initialize. |
|
671 |
||
372 | 672 |
mm := ViewSpacing. |
673 |
||
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
674 |
verticalPanel := VerticalPanelView in:self. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
675 |
vPanelLayout := LayoutFrame origin:(mm @ mm) corner:(1.0@1.0). |
4903 | 676 |
vPanelLayout bottomOffset:(gc font height + (mm * 5)) negated. |
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
677 |
vPanelLayout rightOffset:mm negated. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
678 |
verticalPanel geometryLayout:vPanelLayout. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
679 |
verticalPanel horizontalLayout:#fit. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
680 |
verticalPanel verticalLayout:#bottomFit. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
681 |
|
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
682 |
labelPanel := HorizontalPanelView in:verticalPanel. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
683 |
labelPanel horizontalLayout:#leftSpace. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
684 |
labelPanel verticalLayout:#topSpace. |
3613
0a1963025199
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3260
diff
changeset
|
685 |
labelPanel height:(labelPanel preferredHeight + (mm * 4)). |
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
686 |
|
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
687 |
formLabel := Label in:labelPanel. |
38 | 688 |
self initFormBitmap. |
0 | 689 |
formLabel borderWidth:0. |
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
690 |
"/ formLabel origin:(mm @ mm). |
0 | 691 |
|
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
692 |
textLabel := Label label:'Select' in:labelPanel. |
0 | 693 |
textLabel borderWidth:0. |
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
694 |
"/ textLabel origin:((mm + formLabel width + mm) @ mm). |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
695 |
|
6468 | 696 |
textView := ScrollableView for:TextView in:verticalPanel. |
697 |
textView backgroundColor:(textLabel backgroundColor). |
|
698 |
textView viewBackground:(textLabel viewBackground). |
|
699 |
textView borderWidth:0. |
|
700 |
textView hiddenOnRealize:true. |
|
701 |
||
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
702 |
verticalPanel resize. |
4383 | 703 |
"/ cannot be done here - verticalPanel still has its defaul height and may be |
704 |
"/ not yet filled... |
|
705 |
"/ yPosition := verticalPanel height + (mm * 3). |
|
0 | 706 |
|
1612
e7d3bc88a533
oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
707 |
"/ buttonPanel isNil ifTrue:[ |
e7d3bc88a533
oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
708 |
"/ buttonPanel := HorizontalPanelView origin:(0.0 @ 1.0) corner:(1.0 @ 1.0) in:self. |
e7d3bc88a533
oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
709 |
"/ ]. |
5893 | 710 |
buttonPanel |
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
711 |
bottomInset:0 "mm"; |
5916 | 712 |
topInset:(gc font height + (mm * 4) + ViewSpacing + ViewSpacing) negated. |
5893 | 713 |
buttonPanel |
714 |
borderWidth:0; |
|
372 | 715 |
horizontalLayout:#fitSpace. |
59 | 716 |
|
6468 | 717 |
self initializeButtons |
718 |
||
719 |
" |
|
720 |
|box| |
|
721 |
||
722 |
box := OptionBox title:'hello' numberOfOptions:4. |
|
723 |
box open |
|
724 |
" |
|
725 |
||
726 |
"Modified: / 28-02-2012 / 15:56:57 / cg" |
|
727 |
"Modified: / 26-10-2018 / 11:00:59 / Claus Gittinger" |
|
728 |
! |
|
729 |
||
730 |
initializeButtons |
|
4383 | 731 |
1 to:(buttons size) do:[:index | |
372 | 732 |
|button| |
7 | 733 |
|
372 | 734 |
button := Button label:'press'. |
735 |
button action:[ |
|
736 |
(buttons at:index) turnOffWithoutRedraw. |
|
737 |
self hide. |
|
3804
8a4b07e9ee4e
no need to care for RETURN-keyPress; its already done by the keyboard processor
Claus Gittinger <cg@exept.de>
parents:
3757
diff
changeset
|
738 |
(actions at:index) value |
372 | 739 |
]. |
740 |
buttonPanel addSubView:button. |
|
741 |
buttons at:index put:button. |
|
91 | 742 |
]. |
743 |
||
6468 | 744 |
"/ no longer make the last button the default!! |
745 |
"/ buttons last isReturnButton:true |
|
746 |
||
91 | 747 |
" |
748 |
|box| |
|
749 |
||
750 |
box := OptionBox title:'hello' numberOfOptions:4. |
|
751 |
box open |
|
752 |
" |
|
372 | 753 |
|
6468 | 754 |
"Created: / 26-10-2018 / 11:00:50 / Claus Gittinger" |
133 | 755 |
! ! |
756 |
||
63 | 757 |
!OptionBox methodsFor:'queries'! |
0 | 758 |
|
6499 | 759 |
computePreferredExtent |
59 | 760 |
"return a size to make everything fit into myself" |
761 |
||
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
762 |
|w w1 h buttonPanelsPref vPanelsPref mm| |
0 | 763 |
|
371 | 764 |
mm := ViewSpacing. |
765 |
||
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
766 |
vPanelsPref := verticalPanel preferredExtent. |
371 | 767 |
w1 := (mm * 3) + formLabel width + textLabel width. |
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
768 |
buttonPanelsPref := buttonPanel preferredExtent. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
769 |
w := w1 max:buttonPanelsPref x. |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
770 |
w := w max:vPanelsPref x. |
38 | 771 |
|
3208
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
772 |
h := mm |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
773 |
+ vPanelsPref y |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
774 |
+ mm |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
775 |
+ buttonPanelsPref y |
7b4c5a215af9
use panels, to allow for hooks to add more widgets.
Claus Gittinger <cg@exept.de>
parents:
3201
diff
changeset
|
776 |
+ mm. |
0 | 777 |
|
3905
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
778 |
self subViews do:[:v | |
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
779 |
(v ~~ verticalPanel and:[v ~~ buttonPanel]) ifTrue:[ |
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
780 |
h := h + v preferredExtent y. |
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
781 |
w := w max:(v preferredExtent x). |
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
782 |
]. |
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
783 |
]. |
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
784 |
|
6499 | 785 |
preferredExtent := super computePreferredExtent max:(w @ h). |
3905
9005cad02a02
preferredExtent computation (care for additional components)
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
786 |
^ preferredExtent |
371 | 787 |
|
6499 | 788 |
"Created: / 09-11-2018 / 19:58:19 / Claus Gittinger" |
0 | 789 |
! ! |
197 | 790 |
|
847 | 791 |
!OptionBox class methodsFor:'documentation'! |
243 | 792 |
|
793 |
version |
|
5893 | 794 |
^ '$Header$' |
4223 | 795 |
! |
796 |
||
797 |
version_CVS |
|
5893 | 798 |
^ '$Header$' |
243 | 799 |
! ! |
4490 | 800 |