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