author | Stefan Vogel <sv@exept.de> |
Fri, 28 Feb 2003 18:03:17 +0100 | |
changeset 2700 | d6bc43ddc80f |
parent 2669 | 182aa7a00d83 |
child 2711 | e18e9edca978 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 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 |
||
2212
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
13 |
"{ Package: 'stx:libwidg' }" |
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
14 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
15 |
DialogBox subclass:#OptionBox |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
16 |
instanceVariableNames:'formLabel textLabel buttons actions defaultButtonIndex' |
355 | 17 |
classVariableNames:'WarnBitmap' |
18 |
poolDictionaries:'' |
|
19 |
category:'Views-DialogBoxes' |
|
0 | 20 |
! |
21 |
||
847 | 22 |
!OptionBox class methodsFor:'documentation'! |
7 | 23 |
|
38 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
59 | 27 |
All Rights Reserved |
38 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
7 | 38 |
documentation |
39 |
" |
|
646 | 40 |
CAVEAT: this is a leftover - functionality has been merged into DialogBox |
41 |
PLEASE use one of the `Dialog chooseXXX' methods nstead of OptionBox. |
|
42 |
||
43 |
||
355 | 44 |
Historic note: |
646 | 45 |
originally, ST/X had separate classes for the various entry methods; |
46 |
there were YesNoBox, EnterBox, InfoBox and so on. |
|
47 |
In the meantime, the DialogBox class (and therefore its alias: Dialog) |
|
48 |
is going to duplicate most funcionality found in these classes. |
|
355 | 49 |
|
646 | 50 |
In the future, those existing subclasses' functionality is going to |
51 |
be moved fully into Dialog, and the subclasses will be replaced by dummy |
|
52 |
delegators. (They will be kept for backward compatibility, though). |
|
355 | 53 |
|
54 |
||
38 | 55 |
OptionBoxes are like YesNoBoxes but with as many buttons as you like; |
91 | 56 |
this will finally be a superclass of WarnBox and YesNoBox - or maybe merged |
38 | 57 |
all into DialogBox.. |
97 | 58 |
Use them for multiway questions. |
91 | 59 |
For a consistent user interface, the rightmost button is the default return |
97 | 60 |
button (i.e. pressing return in the box performs this buttons function). |
91 | 61 |
|
646 | 62 |
[author:] |
63 |
Claus Gittinger |
|
91 | 64 |
|
646 | 65 |
[see also:] |
66 |
DialogBox |
|
67 |
" |
|
68 |
! |
|
91 | 69 |
|
646 | 70 |
examples |
71 |
" |
|
72 |
[exBegin] |
|
73 |
|box| |
|
97 | 74 |
|
646 | 75 |
box := OptionBox title:'hello' numberOfOptions:4. |
76 |
box showAtPointer |
|
77 |
[exEnd] |
|
97 | 78 |
|
79 |
||
646 | 80 |
[exBegin] |
81 |
|box| |
|
82 |
box := OptionBox title:'hello' numberOfOptions:3. |
|
83 |
box buttonTitles:#('one' 'two' 'three'). |
|
84 |
box showAtPointer |
|
85 |
[exEnd] |
|
97 | 86 |
|
646 | 87 |
performing an action: |
97 | 88 |
|
646 | 89 |
[exBegin] |
90 |
|box| |
|
91 |
box := OptionBox title:'hello' numberOfOptions:3. |
|
92 |
box buttonTitles:#('one' 'two' 'three'). |
|
93 |
box action:[:which | Transcript show:'button '; |
|
94 |
show: which; |
|
655 | 95 |
showCR:' was pressed']. |
646 | 96 |
box showAtPointer |
97 |
[exEnd] |
|
97 | 98 |
|
646 | 99 |
returning a value: |
100 |
[exBegin] |
|
101 |
|what| |
|
133 | 102 |
|
646 | 103 |
what := OptionBox |
104 |
request:('text has not been accepted.\\Your modifications will be lost when continuing.') withCRs |
|
105 |
label:' Attention' |
|
106 |
form:(WarningBox iconBitmap) |
|
107 |
buttonLabels:#('abort' 'accept' 'continue') |
|
108 |
values:#(#abort #accept #continue). |
|
655 | 109 |
Transcript showCR:what. |
646 | 110 |
[exEnd] |
7 | 111 |
" |
197 | 112 |
! ! |
113 |
||
847 | 114 |
!OptionBox class methodsFor:'instance creation'! |
197 | 115 |
|
116 |
title:titleString numberOfOptions:nOptions |
|
117 |
"create a new optionBox with title, aTitleString and nOptions options" |
|
118 |
||
119 |
|box| |
|
120 |
||
121 |
box := (self basicNew) numberOfOptions:nOptions. |
|
122 |
box device:Screen current. |
|
123 |
box initialize. |
|
124 |
box title:titleString. |
|
125 |
^ box |
|
7 | 126 |
! ! |
127 |
||
2449 | 128 |
!OptionBox class methodsFor:'easy startup'! |
95 | 129 |
|
2585 | 130 |
forRequest:title label:label form:aForm buttonLabels:labels values:values default:defaultValue |
131 |
"create a new optionBox and return it. |
|
132 |
Does not open the box." |
|
133 |
||
134 |
|box| |
|
135 |
||
136 |
box := OptionBox title:title numberOfOptions:(labels size). |
|
137 |
box buttonTitles:labels. |
|
138 |
box defaultButtonIndex:(values indexOf:defaultValue). |
|
139 |
box label:label; form:aForm. |
|
140 |
^ box |
|
141 |
||
142 |
"Modified: / 23.2.2000 / 11:59:32 / cg" |
|
143 |
! |
|
144 |
||
2668 | 145 |
request:title buttonLabels:labels values:values |
146 |
"create a new optionBox, open it modal and return the value of |
|
147 |
the corresponding values collection." |
|
148 |
||
149 |
^ self request:title label:title buttonLabels:labels values:values |
|
150 |
||
151 |
" |
|
152 |
OptionBox |
|
153 |
request:'please select any' |
|
154 |
buttonLabels:#('one' 'two' 'three') |
|
155 |
values:#(1 2 3) |
|
156 |
" |
|
157 |
! |
|
158 |
||
2669 | 159 |
request:title buttonLabels:labels values:values default:defaultValue |
160 |
"create a new optionBox, open it modal and return the value of |
|
161 |
the corresponding values collection. (nil if cancelled)" |
|
162 |
||
163 |
^ self |
|
164 |
request:title label:title form:(YesNoBox iconBitmap) buttonLabels:labels values:values |
|
165 |
default:defaultValue onCancel:defaultValue |
|
166 |
||
167 |
" |
|
168 |
OptionBox |
|
169 |
request:'please select' |
|
170 |
buttonLabels:#('one' 'two' 'three') |
|
171 |
values:#(1 2 3) |
|
172 |
default:3 |
|
173 |
" |
|
174 |
! |
|
175 |
||
2405 | 176 |
request:title label:label buttonLabels:labels values:values |
177 |
"create a new optionBox, open it modal and return the value of |
|
178 |
the corresponding values collection." |
|
179 |
||
180 |
^ self |
|
181 |
request:title label:label form:(YesNoBox iconBitmap) |
|
182 |
buttonLabels:labels values:values default:nil onCancel:nil |
|
2668 | 183 |
|
184 |
" |
|
185 |
OptionBox |
|
186 |
request:'please select' |
|
187 |
label:'select any' |
|
188 |
buttonLabels:#('one' 'two' 'three') |
|
189 |
values:#(1 2 3) |
|
190 |
" |
|
2405 | 191 |
! |
192 |
||
193 |
request:title label:label buttonLabels:labels values:values default:defaultValue |
|
194 |
"create a new optionBox, open it modal and return the value of |
|
195 |
the corresponding values collection. (nil if cancelled)" |
|
196 |
||
197 |
^ self |
|
198 |
request:title label:label form:(YesNoBox iconBitmap) buttonLabels:labels values:values |
|
199 |
default:defaultValue onCancel:defaultValue |
|
2668 | 200 |
|
201 |
" |
|
202 |
OptionBox |
|
203 |
request:'please select' |
|
204 |
label:'select any' |
|
205 |
buttonLabels:#('one' 'two' 'three') |
|
206 |
values:#(1 2 3) |
|
207 |
default:3 |
|
208 |
" |
|
2405 | 209 |
! |
210 |
||
211 |
request:title label:label buttonLabels:labels values:values default:defaultValue onCancel:cancelValue |
|
212 |
"create a new optionBox, open it modal and return the value of |
|
213 |
the corresponding values collection. (nil if cancelled)" |
|
214 |
||
215 |
^ self |
|
216 |
request:title label:label form:(YesNoBox iconBitmap) buttonLabels:labels values:values |
|
217 |
default:defaultValue onCancel:cancelValue |
|
2668 | 218 |
|
219 |
" |
|
220 |
OptionBox |
|
221 |
request:'please select' |
|
222 |
label:'select any' |
|
223 |
buttonLabels:#('one' 'two' 'three') |
|
224 |
values:#(1 2 3) |
|
225 |
default:3 |
|
226 |
onCancel:2 |
|
227 |
" |
|
2405 | 228 |
! |
229 |
||
133 | 230 |
request:title label:label form:aForm buttonLabels:labels values:values |
231 |
"create a new optionBox, open it modal and return the value of |
|
232 |
the corresponding values collection." |
|
233 |
||
2390 | 234 |
^ self request:title label:label form:aForm buttonLabels:labels values:values default:nil onCancel:nil |
2668 | 235 |
|
236 |
" |
|
237 |
OptionBox |
|
238 |
request:'please select' |
|
239 |
label:'select any' |
|
240 |
form:(WarningBox iconBitmap) |
|
241 |
buttonLabels:#('one' 'two' 'three') |
|
242 |
values:#(1 2 3) |
|
243 |
" |
|
133 | 244 |
! |
245 |
||
246 |
request:title label:label form:aForm buttonLabels:labels values:values default:defaultValue |
|
95 | 247 |
"create a new optionBox, open it modal and return the value of |
2389 | 248 |
the corresponding values collection. (nil if cancelled)" |
95 | 249 |
|
2390 | 250 |
^ self |
251 |
request:title label:label form:aForm buttonLabels:labels values:values |
|
252 |
default:defaultValue onCancel:defaultValue |
|
2668 | 253 |
|
254 |
" |
|
255 |
OptionBox |
|
256 |
request:'please select' |
|
257 |
label:'select any' |
|
258 |
form:(WarningBox iconBitmap) |
|
259 |
buttonLabels:#('one' 'two' 'three') |
|
260 |
values:#(1 2 3) |
|
261 |
default:3 |
|
262 |
" |
|
2390 | 263 |
! |
264 |
||
265 |
request:title label:label form:aForm buttonLabels:labels values:values default:defaultValue onCancel:cancelValue |
|
266 |
"create a new optionBox, open it modal and return the value of |
|
267 |
the corresponding values collection. (cancelValue if cancelled)" |
|
268 |
||
2162 | 269 |
|box retVal| |
95 | 270 |
|
2390 | 271 |
retVal := cancelValue. |
2585 | 272 |
box := self |
273 |
forRequest:title |
|
274 |
label:label |
|
275 |
form:aForm |
|
276 |
buttonLabels:labels |
|
277 |
values:values |
|
278 |
default:defaultValue. |
|
279 |
||
2162 | 280 |
box action:[:n | retVal := values at:n]. |
95 | 281 |
box showAtPointer. |
920 | 282 |
box destroy. |
2389 | 283 |
|
2162 | 284 |
^ retVal |
95 | 285 |
|
286 |
" |
|
2668 | 287 |
OptionBox |
288 |
request:'please select' |
|
289 |
label:'select any' |
|
290 |
form:(WarningBox iconBitmap) |
|
291 |
buttonLabels:#('one' 'two' 'three') |
|
292 |
values:#(1 2 3) |
|
293 |
default:3 |
|
294 |
onCancel:nil |
|
95 | 295 |
" |
920 | 296 |
|
2162 | 297 |
"Modified: / 23.2.2000 / 11:59:32 / cg" |
95 | 298 |
! ! |
299 |
||
197 | 300 |
!OptionBox methodsFor:'accessing'! |
301 |
||
302 |
action:actionBlock |
|
303 |
"define a single the action for all buttons. |
|
304 |
The action will be evaluated with the button index as argument." |
|
305 |
||
306 |
buttons keysAndValuesDo:[:index :button | |
|
307 |
button action:[ |
|
308 |
button turnOffWithoutRedraw. |
|
309 |
self hide. |
|
310 |
actionBlock value:index |
|
311 |
] |
|
312 |
]. |
|
313 |
! |
|
314 |
||
315 |
actions:actionBlocks |
|
316 |
"define the actions" |
|
0 | 317 |
|
197 | 318 |
actions := actionBlocks |
319 |
! |
|
320 |
||
321 |
buttonTitles:titles actions:actionBlocks |
|
322 |
"define both button titles and actions" |
|
323 |
||
324 |
self buttonTitles:titles. |
|
325 |
actions := actionBlocks. |
|
326 |
! |
|
0 | 327 |
|
197 | 328 |
buttons |
329 |
"return the buttons collection" |
|
330 |
||
331 |
^ buttons |
|
332 |
! |
|
333 |
||
334 |
defaultButtonIndex:index |
|
847 | 335 |
"define which button is the default (i.e. return-) button. |
336 |
By default, no returnButton is setup. The argument must be an |
|
337 |
index 1..nButtons, or nil" |
|
338 |
||
197 | 339 |
defaultButtonIndex notNil ifTrue:[ |
847 | 340 |
(buttons at:defaultButtonIndex) isReturnButton:false |
197 | 341 |
]. |
342 |
(index notNil and:[index ~~ 0]) ifTrue:[ |
|
847 | 343 |
defaultButtonIndex := index. |
344 |
defaultButtonIndex notNil ifTrue:[ |
|
345 |
(buttons at:defaultButtonIndex) isReturnButton:true |
|
346 |
]. |
|
197 | 347 |
] |
847 | 348 |
|
349 |
"Modified: 18.10.1996 / 14:53:36 / cg" |
|
197 | 350 |
! |
351 |
||
352 |
numberOfOptions |
|
353 |
"return the number of options" |
|
354 |
||
355 |
^ buttons size |
|
356 |
! |
|
357 |
||
358 |
numberOfOptions:nOptions |
|
847 | 359 |
"set the number of options - this is a private interface" |
197 | 360 |
|
361 |
buttons := (OrderedCollection new:nOptions) grow:nOptions. |
|
362 |
actions := (OrderedCollection new:nOptions) grow:nOptions |
|
847 | 363 |
|
364 |
"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
|
365 |
! ! |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
366 |
|
2227 | 367 |
!OptionBox methodsFor:'accessing-look'! |
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
368 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
369 |
buttonTitles:titles |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
370 |
"set the button titles" |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
371 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
372 |
titles keysAndValuesDo:[:index :aString | |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
373 |
|b| |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
374 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
375 |
(b := buttons at:index) label:aString. |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
376 |
b resize. |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
377 |
]. |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
378 |
shown ifTrue:[self resize] |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
379 |
! |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
380 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
381 |
form:aFormOrImage |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
382 |
"set the image shown in the label-view" |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
383 |
|
2212
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
384 |
|mm| |
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
385 |
|
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
386 |
mm := ViewSpacing. |
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
387 |
formLabel form:aFormOrImage. |
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
388 |
textLabel origin:((mm + formLabel width + mm) @ mm). |
7475e8be57bb
recompute label origin, if the form changes
Claus Gittinger <cg@exept.de>
parents:
2162
diff
changeset
|
389 |
|
740
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
390 |
! |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
391 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
392 |
formLabel |
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
393 |
"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
|
394 |
|
2d5cb01c7e11
no need for focusSequence - DialogBox does it
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
395 |
^ formLabel |
197 | 396 |
! |
0 | 397 |
|
2476 | 398 |
image:aFormOrImage |
399 |
"set the image shown in the label-view" |
|
400 |
||
401 |
self form:aFormOrImage |
|
402 |
||
403 |
"Created: / 16.11.2001 / 15:20:02 / cg" |
|
404 |
! |
|
405 |
||
2328 | 406 |
textLabel |
407 |
"return the label-view which displays a message string" |
|
408 |
||
409 |
^ textLabel |
|
410 |
! |
|
411 |
||
0 | 412 |
title:aString |
16 | 413 |
"set the boxes title" |
0 | 414 |
|
16 | 415 |
aString ~= textLabel label ifTrue:[ |
59 | 416 |
textLabel label:aString withoutSeparators. |
110 | 417 |
textLabel forceResize. |
97 | 418 |
shown ifTrue:[self resize] |
16 | 419 |
] |
0 | 420 |
! |
421 |
||
97 | 422 |
title:aString numberOfOptions:nOptions |
423 |
"set the boxes title and number of options" |
|
424 |
||
425 |
self title:aString. |
|
426 |
buttons grow:nOptions. |
|
427 |
actions grow:nOptions |
|
197 | 428 |
! ! |
97 | 429 |
|
197 | 430 |
!OptionBox methodsFor:'events'! |
77 | 431 |
|
197 | 432 |
keyPress:aKey x:x y:y |
2700 | 433 |
"return-key duplicates ok-function if acceptReturnAsOK is true" |
77 | 434 |
|
490 | 435 |
<resource: #keyboard (#Return)> |
436 |
||
197 | 437 |
|action| |
77 | 438 |
|
197 | 439 |
defaultButtonIndex notNil ifTrue:[ |
490 | 440 |
(aKey == #Return) ifTrue:[ |
441 |
self hide. |
|
442 |
action := actions at:defaultButtonIndex. |
|
443 |
action notNil ifTrue:[ |
|
444 |
action value |
|
445 |
] |
|
446 |
] |
|
197 | 447 |
]. |
448 |
super keyPress:aKey x:x y:y |
|
490 | 449 |
|
450 |
"Modified: 7.3.1996 / 13:17:36 / cg" |
|
197 | 451 |
! ! |
0 | 452 |
|
2523 | 453 |
!OptionBox methodsFor:'initialization'! |
7 | 454 |
|
197 | 455 |
initFormBitmap |
456 |
WarnBitmap isNil ifTrue:[ |
|
1914 | 457 |
WarnBitmap := WarningBox iconBitmap. |
458 |
"/ WarnBitmap := Image fromFile:'bitmaps/Warning.xbm' resolution:100 on:Display |
|
0 | 459 |
]. |
197 | 460 |
formLabel form:WarnBitmap |
899 | 461 |
|
1914 | 462 |
"Modified: / 25.5.1999 / 16:08:06 / cg" |
0 | 463 |
! |
464 |
||
465 |
initialize |
|
372 | 466 |
|nButt mm| |
0 | 467 |
|
468 |
super initialize. |
|
469 |
||
372 | 470 |
mm := ViewSpacing. |
471 |
||
38 | 472 |
formLabel := Label in:self. |
473 |
self initFormBitmap. |
|
0 | 474 |
formLabel borderWidth:0. |
372 | 475 |
formLabel origin:(mm @ mm). |
0 | 476 |
|
188 | 477 |
textLabel := Label label:'Select' in:self. |
0 | 478 |
textLabel borderWidth:0. |
372 | 479 |
textLabel origin:((mm + formLabel width + mm) @ mm). |
0 | 480 |
|
1612
e7d3bc88a533
oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
481 |
"/ buttonPanel isNil ifTrue:[ |
e7d3bc88a533
oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
482 |
"/ 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
|
483 |
"/ ]. |
130 | 484 |
buttonPanel |
372 | 485 |
bottomInset:mm; |
486 |
topInset:(font height + mm * 2) negated. |
|
130 | 487 |
buttonPanel |
372 | 488 |
borderWidth:0; |
489 |
horizontalLayout:#fitSpace. |
|
59 | 490 |
|
0 | 491 |
nButt := buttons size. |
492 |
||
7 | 493 |
1 to:nButt do:[:index | |
372 | 494 |
|button| |
7 | 495 |
|
372 | 496 |
button := Button label:'press'. |
497 |
button action:[ |
|
498 |
|action| |
|
7 | 499 |
|
372 | 500 |
(buttons at:index) turnOffWithoutRedraw. |
501 |
self hide. |
|
502 |
action := actions at:index. |
|
503 |
action notNil ifTrue:[ |
|
504 |
action value |
|
505 |
] |
|
506 |
]. |
|
133 | 507 |
"/ index == nButt ifTrue:[ |
508 |
"/ button isReturnButton:true |
|
509 |
"/ ]. |
|
372 | 510 |
buttonPanel addSubView:button. |
511 |
buttons at:index put:button. |
|
91 | 512 |
]. |
513 |
||
514 |
" |
|
515 |
|box| |
|
516 |
||
517 |
box := OptionBox title:'hello' numberOfOptions:4. |
|
518 |
box open |
|
519 |
" |
|
372 | 520 |
|
1612
e7d3bc88a533
oops - two buttonPanels where created (MD's fix).
Claus Gittinger <cg@exept.de>
parents:
953
diff
changeset
|
521 |
"Modified: / 27.7.1998 / 19:37:17 / cg" |
133 | 522 |
! ! |
523 |
||
63 | 524 |
!OptionBox methodsFor:'queries'! |
0 | 525 |
|
130 | 526 |
preferredExtent |
59 | 527 |
"return a size to make everything fit into myself" |
528 |
||
371 | 529 |
|w w1 h maxH prefPanel mm| |
0 | 530 |
|
799 | 531 |
"/ If I have an explicit preferredExtent .. |
532 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
533 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
534 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
535 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
655
diff
changeset
|
536 |
|
371 | 537 |
mm := ViewSpacing. |
538 |
||
539 |
w1 := (mm * 3) + formLabel width + textLabel width. |
|
130 | 540 |
prefPanel := buttonPanel preferredExtent. |
91 | 541 |
w := w1 max:prefPanel x. |
38 | 542 |
|
97 | 543 |
"/ maxH := 0. |
544 |
"/ buttons do:[:button | |
|
130 | 545 |
"/ maxH := maxH max:(button preferredExtent y) |
97 | 546 |
"/ ]. |
547 |
maxH := prefPanel y. |
|
0 | 548 |
|
371 | 549 |
h := (mm * 4) |
550 |
+ ((formLabel height) max:(textLabel height)) |
|
551 |
+ maxH. |
|
0 | 552 |
|
59 | 553 |
^ w @ h |
371 | 554 |
|
799 | 555 |
"Modified: 19.7.1996 / 20:45:11 / cg" |
0 | 556 |
! ! |
197 | 557 |
|
847 | 558 |
!OptionBox class methodsFor:'documentation'! |
243 | 559 |
|
560 |
version |
|
2700 | 561 |
^ '$Header: /cvs/stx/stx/libwidg/OptionBox.st,v 1.55 2003-02-28 17:02:33 stefan Exp $' |
243 | 562 |
! ! |