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