author | Claus Gittinger <cg@exept.de> |
Fri, 23 Jan 1998 18:23:05 +0100 | |
changeset 766 | 67d7a6bc6780 |
parent 713 | 548898fdd1dc |
child 902 | 4851101e5b8c |
permissions | -rw-r--r-- |
366 | 1 |
" |
2 |
COPYRIGHT (c) 1996 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
||
13 |
||
14 |
ApplicationModel subclass:#SimpleDialog |
|
431 | 15 |
instanceVariableNames:'accept cancel close escapeIsCancel postBuildBlock postOpenBlock |
16 |
preBuildBlock' |
|
366 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
19 |
category:'Interface-Framework' |
|
20 |
! |
|
21 |
||
22 |
!SimpleDialog class methodsFor:'documentation'! |
|
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1996 by eXept Software AG |
|
27 |
All Rights Reserved |
|
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 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
Since many ST-80 classes are subclasses of SompleDialog, this class |
|
42 |
is provided here to allow easier porting of ST-80 code. |
|
43 |
||
44 |
It does not (currently) provide much functionality and is NOT |
|
45 |
compatible to the corresponding ST80 class; therefore, manual |
|
46 |
changes have to be made to get those applications to run under ST/X. |
|
47 |
(but at least, this enables you to fileIn that code and have a superclass |
|
48 |
for them) |
|
49 |
||
50 |
However, as time goes by, ST/X applications may be converted to use the |
|
51 |
ApplicationModel / SimpleDialog framework as well. |
|
52 |
||
53 |
Notice: this class was implemented using protocol information |
|
54 |
from alpha testers and PD code - it may not be complete or compatible to |
|
55 |
the corresponding ST-80 class. If you encounter any incompatibilities, |
|
56 |
please forward a note to the ST/X team. |
|
57 |
||
58 |
||
59 |
[author:] |
|
60 |
Claus Gittinger |
|
61 |
||
62 |
[see also:] |
|
63 |
StandardSystemView |
|
64 |
WindowGroup DeviceWorkstation DialogBox |
|
65 |
" |
|
66 |
||
67 |
! ! |
|
68 |
||
431 | 69 |
!SimpleDialog methodsFor:'accessing'! |
70 |
||
71 |
accept |
|
605 | 72 |
"return the valueholder which gets set by the accept button" |
431 | 73 |
|
74 |
^ accept |
|
605 | 75 |
|
76 |
"Modified: 17.6.1997 / 14:09:48 / cg" |
|
431 | 77 |
! |
78 |
||
79 |
bindings |
|
80 |
^ builder bindings |
|
81 |
! |
|
82 |
||
83 |
cancel |
|
605 | 84 |
"return the valueholder which gets set by the cancel button" |
431 | 85 |
|
86 |
^ cancel |
|
605 | 87 |
|
88 |
"Modified: 17.6.1997 / 14:09:55 / cg" |
|
431 | 89 |
! |
90 |
||
91 |
closeChannel |
|
92 |
"return the value of the instance variable 'close' (automatically generated)" |
|
93 |
||
94 |
^ close |
|
95 |
! |
|
96 |
||
97 |
escapeIsCancel |
|
98 |
"return the value of the instance variable 'escapeIsCancel' (automatically generated)" |
|
99 |
||
100 |
^ escapeIsCancel! |
|
101 |
||
102 |
escapeIsCancel:something |
|
103 |
"set the value of the instance variable 'escapeIsCancel' (automatically generated)" |
|
104 |
||
105 |
escapeIsCancel := something.! |
|
106 |
||
107 |
postBuildBlock:something |
|
108 |
"set the value of the instance variable 'postBuildBlock' (automatically generated)" |
|
109 |
||
110 |
postBuildBlock := something.! |
|
111 |
||
112 |
postOpenBlock:something |
|
113 |
"set the value of the instance variable 'postOpenBlock' (automatically generated)" |
|
114 |
||
115 |
postOpenBlock := something.! |
|
116 |
||
117 |
preBuildBlock:something |
|
118 |
"set the value of the instance variable 'preBuildBlock' (automatically generated)" |
|
119 |
||
120 |
preBuildBlock := something.! |
|
121 |
||
122 |
source:anApplication |
|
123 |
builder source:anApplication |
|
124 |
! ! |
|
125 |
||
481 | 126 |
!SimpleDialog methodsFor:'accessing - window'! |
127 |
||
128 |
minWidth:nPixels |
|
129 |
|w box | |
|
130 |
||
131 |
w := builder window width. |
|
132 |
builder window width:(w max:nPixels). |
|
133 |
||
134 |
"/ box := builder window displayBox. |
|
135 |
"/ box width: (box width max: nPixels). |
|
136 |
"/ builder window displayBox: box |
|
137 |
||
138 |
"Modified: 3.3.1997 / 21:56:27 / cg" |
|
139 |
! ! |
|
140 |
||
431 | 141 |
!SimpleDialog methodsFor:'events'! |
142 |
||
143 |
closeAccept |
|
605 | 144 |
"accept was pressed. close the dialog" |
145 |
||
431 | 146 |
self requestForWindowClose ifTrue:[ |
147 |
self closeWindow |
|
148 |
] |
|
605 | 149 |
|
150 |
"Modified: 17.6.1997 / 14:10:23 / cg" |
|
431 | 151 |
! |
152 |
||
153 |
closeCancel |
|
605 | 154 |
"cancel was pressed. close the dialog" |
155 |
||
431 | 156 |
self requestForWindowClose ifTrue:[ |
157 |
self closeWindow |
|
158 |
] |
|
605 | 159 |
|
160 |
"Modified: 17.6.1997 / 14:10:29 / cg" |
|
431 | 161 |
! |
162 |
||
163 |
closeWindow |
|
605 | 164 |
"close the dialog" |
165 |
||
431 | 166 |
self closeChannel value:true. |
167 |
builder window hide |
|
605 | 168 |
|
169 |
"Modified: 17.6.1997 / 14:10:38 / cg" |
|
431 | 170 |
! |
171 |
||
172 |
requestForWindowClose |
|
173 |
^ true |
|
174 |
! ! |
|
175 |
||
713 | 176 |
!SimpleDialog methodsFor:'forced actions'! |
177 |
||
178 |
doAccept |
|
179 |
accept value:true |
|
180 |
||
181 |
"Created: 18.10.1997 / 05:18:09 / cg" |
|
182 |
"Modified: 18.10.1997 / 05:18:28 / cg" |
|
183 |
! |
|
184 |
||
185 |
doCancel |
|
186 |
cancel value:true |
|
187 |
||
188 |
"Created: 18.10.1997 / 05:18:22 / cg" |
|
189 |
! ! |
|
190 |
||
431 | 191 |
!SimpleDialog methodsFor:'initialization'! |
192 |
||
193 |
initialize |
|
194 |
accept := false asValue. |
|
195 |
close := false asValue. |
|
196 |
cancel := false asValue. |
|
197 |
builder aspectAt:#accept put:accept. |
|
198 |
builder aspectAt:#close put:close. |
|
199 |
builder aspectAt:#cancel put:cancel. |
|
200 |
escapeIsCancel := true. |
|
476
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
201 |
! |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
202 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
203 |
initializeBuilderFor:aView |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
204 |
aView notNil ifTrue:[ |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
205 |
builder window:aView. |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
206 |
] |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
207 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
208 |
"Created: 3.3.1997 / 16:23:04 / cg" |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
209 |
! |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
210 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
211 |
initializeWindowFor:aView |
679 | 212 |
|v| |
476
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
213 |
|
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
214 |
(v := aView) isNil ifTrue:[ |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
215 |
v := ModalBox new. |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
216 |
]. |
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
217 |
|
481 | 218 |
builder setupWindowFor:v. |
476
628766c580c3
added dummy #initializeBuilderFor: and #initializeWindowFor:
Claus Gittinger <cg@exept.de>
parents:
466
diff
changeset
|
219 |
|
481 | 220 |
"Modified: 3.3.1997 / 20:39:46 / cg" |
431 | 221 |
! ! |
222 |
||
429 | 223 |
!SimpleDialog methodsFor:'interface opening'! |
224 |
||
431 | 225 |
allButOpenFrom:aSpec |
226 |
"create my views but do not open the main window" |
|
227 |
||
228 |
super allButOpenFrom:aSpec. |
|
229 |
self preOpen |
|
230 |
! |
|
231 |
||
429 | 232 |
openFor:anApplication interface:aSelector |
465 | 233 |
"open the dialog for some appModel from a given spec; |
234 |
Return true if accepted, false if canceled" |
|
235 |
||
464
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
236 |
^ self openFor:anApplication interface:aSelector withBindings:nil |
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
237 |
|
465 | 238 |
"Modified: 28.2.1997 / 16:22:08 / cg" |
464
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
239 |
! |
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
240 |
|
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
241 |
openFor:anApplication interface:aSelector withBindings:bindings |
713 | 242 |
"open the dialog for some appModel from a given specSymbol; |
243 |
the application must provide an interfaceSpec for that symbol. |
|
244 |
The bindings argument may provide overwriting bindings for the |
|
245 |
dialog. |
|
246 |
Return true if accepted, false if canceled" |
|
247 |
||
248 |
^ self |
|
249 |
openFor:anApplication |
|
250 |
interfaceSpec:(anApplication class interfaceSpecFor:aSelector) |
|
251 |
withBindings:bindings |
|
252 |
||
253 |
"Modified: 18.10.1997 / 04:43:13 / cg" |
|
254 |
! |
|
255 |
||
256 |
openFor:anApplication interfaceSpec:aSpec withBindings:bindings |
|
465 | 257 |
"open the dialog for some appModel from a given spec; |
258 |
the bindings argument may provide overwriting bindings for the |
|
259 |
dialog. |
|
260 |
Return true if accepted, false if canceled" |
|
261 |
||
464
25e6380399c6
allow additional bindings to be passed with #openDialogInterface
Claus Gittinger <cg@exept.de>
parents:
462
diff
changeset
|
262 |
builder addBindings:bindings. |
431 | 263 |
self source:anApplication. |
713 | 264 |
^ self openFrom:aSpec |
429 | 265 |
|
465 | 266 |
"Modified: 28.2.1997 / 16:22:00 / cg" |
713 | 267 |
"Created: 18.10.1997 / 04:41:29 / cg" |
429 | 268 |
! |
269 |
||
270 |
openFrom:anInterfaceSpec |
|
466 | 271 |
"open the dialog from a given spec; |
272 |
return true if accepted, false if canceled" |
|
273 |
||
429 | 274 |
self allButOpenFrom:anInterfaceSpec. |
275 |
self openDialog. |
|
431 | 276 |
^ accept value |
277 |
||
466 | 278 |
"Modified: 28.2.1997 / 16:40:36 / cg" |
431 | 279 |
! |
280 |
||
713 | 281 |
postBuildWith:aBuilder |
282 |
"this is sent after the dialogs widgets have been created |
|
283 |
(but before the dialog is opened). |
|
284 |
If a postBuildBlock was set, evaluate it here." |
|
285 |
||
286 |
postBuildBlock notNil ifTrue:[ |
|
287 |
postBuildBlock numArgs == 0 ifTrue:[ |
|
288 |
postBuildBlock value |
|
289 |
] ifFalse:[ |
|
290 |
postBuildBlock value:aBuilder |
|
291 |
] |
|
292 |
]. |
|
293 |
super postBuildWith:aBuilder |
|
294 |
||
295 |
"Created: 18.10.1997 / 05:17:12 / cg" |
|
296 |
! |
|
297 |
||
298 |
postOpenWith:aBuilder |
|
299 |
"this is sent after the dialogs main window is opened. |
|
300 |
If a postOpenBlock was set, evaluate it here." |
|
301 |
||
302 |
postOpenBlock notNil ifTrue:[ |
|
303 |
postOpenBlock numArgs == 0 ifTrue:[ |
|
304 |
postOpenBlock value |
|
305 |
] ifFalse:[ |
|
306 |
postOpenBlock value:aBuilder |
|
307 |
] |
|
308 |
]. |
|
309 |
super postOpenWith:aBuilder |
|
310 |
||
311 |
"Created: 18.10.1997 / 05:15:48 / cg" |
|
312 |
! |
|
313 |
||
314 |
preBuildWith:aBuilder |
|
315 |
"this is sent before the dialogs widgets are created. |
|
316 |
If a preBuildBlock was set, evaluate it here." |
|
317 |
||
318 |
preBuildBlock notNil ifTrue:[ |
|
319 |
preBuildBlock numArgs == 0 ifTrue:[ |
|
320 |
preBuildBlock value |
|
321 |
] ifFalse:[ |
|
322 |
preBuildBlock value:aBuilder |
|
323 |
] |
|
324 |
]. |
|
325 |
super preBuildWith:aBuilder |
|
326 |
||
327 |
"Created: 18.10.1997 / 15:02:27 / cg" |
|
328 |
! |
|
329 |
||
431 | 330 |
preOpen |
605 | 331 |
"arrange for #closeAccept & #closeCancel to be invoked when |
332 |
either accept or close is triggered |
|
333 |
(usually the models of corresponding buttons)" |
|
334 |
||
431 | 335 |
accept onChangeSend:#closeAccept to:self. |
336 |
cancel onChangeSend:#closeCancel to:self. |
|
429 | 337 |
|
605 | 338 |
"Modified: 17.6.1997 / 14:13:16 / cg" |
429 | 339 |
! ! |
340 |
||
366 | 341 |
!SimpleDialog methodsFor:'queries'! |
342 |
||
343 |
defaultWindowType |
|
344 |
"SimpleDialogs come up modal, by default" |
|
345 |
||
346 |
^ #dialog |
|
347 |
||
348 |
"Modified: 14.2.1997 / 22:17:20 / cg" |
|
349 |
! ! |
|
350 |
||
766
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
351 |
!SimpleDialog methodsFor:'startup'! |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
352 |
|
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
353 |
openInterface:aWindowSpec |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
354 |
"open a standard interface. |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
355 |
Redefned to return the accept value instead of the builder." |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
356 |
|
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
357 |
super openInterface:aWindowSpec. |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
358 |
^ accept value. |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
359 |
|
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
360 |
"Created: / 23.1.1998 / 18:19:57 / cg" |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
361 |
"Modified: / 23.1.1998 / 18:20:54 / cg" |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
362 |
! ! |
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
363 |
|
366 | 364 |
!SimpleDialog class methodsFor:'documentation'! |
365 |
||
366 |
version |
|
766
67d7a6bc6780
simpledialog open - returns the accept-value
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
367 |
^ '$Header: /cvs/stx/stx/libview2/SimpleDialog.st,v 1.14 1998-01-23 17:23:05 cg Exp $' |
366 | 368 |
! ! |