author | Claus Gittinger <cg@exept.de> |
Thu, 17 Oct 2002 13:24:55 +0200 | |
changeset 1634 | 64f2605c5b51 |
parent 1633 | 07765ef65021 |
child 1669 | 6130b670c22e |
permissions | -rw-r--r-- |
1419 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
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 |
"{ Package: 'stx:libview2' }" |
|
14 |
||
15 |
Model subclass:#ApplicationModel |
|
16 |
instanceVariableNames:'builder resources device masterApplication' |
|
17 |
classVariableNames:'DefaultLabels DefaultVisuals' |
|
1417 | 18 |
poolDictionaries:'' |
1419 | 19 |
category:'Interface-Framework' |
138 | 20 |
! |
21 |
||
1419 | 22 |
ApplicationModel class instanceVariableNames:'ClassResources' |
23 |
||
24 |
" |
|
25 |
No other class instance variables are inherited by this class. |
|
26 |
" |
|
1350 | 27 |
! |
28 |
||
1419 | 29 |
!ApplicationModel class methodsFor:'documentation'! |
30 |
||
1417 | 31 |
copyright |
1419 | 32 |
" |
33 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
34 |
All Rights Reserved |
|
35 |
||
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
! |
|
44 |
||
45 |
documentation |
|
46 |
" |
|
47 |
Since many ST-80 classes are subclasses of ApplicationModel, this class |
|
48 |
is provided here to allow easier porting of ST-80 code. |
|
49 |
||
50 |
It does not (currently) provide all functionality and is NOT |
|
51 |
compatible to the corresponding ST80 class; therefore, manual |
|
52 |
changes have to be made to get those applications to run under ST/X. |
|
53 |
(but at least, this enables you to fileIn that code and have a superclass |
|
54 |
for them) |
|
55 |
||
56 |
As time goes by, ST/X applications are going to be converted to |
|
57 |
become subclasses of this abstract class - see Launcher for a |
|
58 |
first concrete example. |
|
59 |
||
60 |
||
61 |
ApplicationModel is prepared to build a view from a windowSpec, as |
|
62 |
created by the windowBuilder. If your subclass does not provide such |
|
63 |
a spec, you should at least redefine: |
|
64 |
||
65 |
#openInterface - to create a topview and open it |
|
66 |
||
67 |
you may want to redefine: |
|
68 |
||
69 |
#closeRequest - to catch window closing |
|
70 |
#focusSequence - to define a sequence for focus-stepping |
|
71 |
||
72 |
||
73 |
Once the interfaceBuilder is finished & released, subclasses can |
|
74 |
alternatively provide the spec via a #windowSpec method. |
|
75 |
||
76 |
The classResources have been put into this class to allow ST/X |
|
77 |
applications (which used to be subclasses of StandardSystemView) |
|
78 |
to migrate smoothly into ApplicationModels (which is better design ...). |
|
79 |
||
80 |
||
81 |
[Instance variables:] |
|
82 |
resources ResourcePack language string translation |
|
83 |
||
84 |
builder WindowBuilder a builder who knows how to create |
|
85 |
a window hierarchy from a specification |
|
86 |
||
87 |
||
88 |
Notice: this class was implemented using protocol information |
|
89 |
from alpha testers and PD code - it may not be complete or compatible to |
|
90 |
the corresponding ST-80 class. If you encounter any incompatibilities, |
|
91 |
please forward a note to the ST/X team. |
|
92 |
||
93 |
||
94 |
[author:] |
|
95 |
Claus Gittinger |
|
96 |
||
97 |
[see also:] |
|
98 |
StandardSystemView |
|
99 |
WindowGroup DeviceWorkstation |
|
100 |
" |
|
101 |
! ! |
|
102 |
||
103 |
!ApplicationModel class methodsFor:'initialization'! |
|
104 |
||
105 |
initialize |
|
106 |
self == ApplicationModel ifTrue:[ |
|
107 |
Smalltalk addDependent:self |
|
108 |
]. |
|
109 |
DefaultLabels isNil ifTrue:[ |
|
110 |
DefaultLabels := IdentityDictionary new |
|
111 |
]. |
|
112 |
DefaultVisuals isNil ifTrue:[ |
|
113 |
DefaultVisuals := IdentityDictionary new |
|
114 |
]. |
|
115 |
||
116 |
" |
|
117 |
ApplicationModel initialize |
|
118 |
" |
|
119 |
||
120 |
"Modified: 28.1.1997 / 12:31:38 / cg" |
|
121 |
! ! |
|
122 |
||
123 |
!ApplicationModel class methodsFor:'instance creation'! |
|
124 |
||
125 |
new |
|
126 |
"return a new initialized instance" |
|
127 |
||
128 |
|inst| |
|
129 |
||
1590 | 130 |
inst := self basicNew. |
1419 | 131 |
inst basicInitialize. |
132 |
inst initialize. |
|
133 |
^ inst |
|
134 |
||
135 |
"Modified: 24.4.1996 / 09:42:14 / cg" |
|
136 |
! |
|
137 |
||
138 |
onDevice:aDevice |
|
139 |
"return a new initialized instance, which shall open its interface |
|
140 |
on aDevice." |
|
141 |
||
142 |
^ (super basicNew basicInitialize |
|
143 |
setDevice:aDevice) initialize |
|
144 |
||
145 |
"Modified: 24.4.1996 / 09:42:14 / cg" |
|
146 |
"Created: 5.7.1996 / 12:19:15 / cg" |
|
147 |
! ! |
|
148 |
||
149 |
!ApplicationModel class methodsFor:'accessing'! |
|
150 |
||
151 |
application |
|
152 |
^ self |
|
153 |
||
154 |
! ! |
|
155 |
||
156 |
!ApplicationModel class methodsFor:'active help'! |
|
157 |
||
1538 | 158 |
flyByHelpSpec |
159 |
"default is: no help-spec (should be redefined by concrete class if help is wanted)." |
|
160 |
||
161 |
^ IdentityDictionary new. |
|
162 |
! |
|
163 |
||
1419 | 164 |
helpSpec |
1431 | 165 |
"default is: no help-spec (should be redefined by concrete class if help is wanted)." |
166 |
||
1419 | 167 |
^ IdentityDictionary new. |
168 |
! ! |
|
169 |
||
170 |
!ApplicationModel class methodsFor:'bindings'! |
|
171 |
||
172 |
actionFor:aKey |
|
173 |
"sent by the builder to ask for an actionBlock for |
|
174 |
a Button. The argument, aKey comes from an UI-spec |
|
175 |
for a buttons #action property. |
|
176 |
Here, a corresponding message is sent to myself, |
|
177 |
which ought to be defined in the application subclass. |
|
178 |
Alternatively, a subclass may redefine this method, to provide |
|
179 |
actionBlocks from a Dictionary or whatever. |
|
180 |
Typically, a block is returned there." |
|
181 |
||
182 |
^ nil |
|
183 |
||
184 |
||
185 |
! |
|
186 |
||
187 |
actionFor:aKey withValue:aValue |
|
188 |
"sent by the builder to ask for an actionBlock for |
|
189 |
a Button which passes a value to the actionMethod. |
|
190 |
The argument, aKey comes from an UI-spec |
|
191 |
for a buttons #action property. |
|
192 |
Here, a corresponding message is sent to myself, |
|
193 |
which ought to be defined in the application subclass. |
|
194 |
Alternatively, a subclass may redefine this method, to provide |
|
195 |
actionBlocks from a Dictionary or whatever. |
|
196 |
Typically, a block is returned there." |
|
197 |
||
198 |
^ nil |
|
199 |
||
200 |
||
201 |
! |
|
202 |
||
203 |
aspectFor:aKey |
|
204 |
"sent by the builder to ask for an aspect (a data model). |
|
205 |
The argument, aKey comes from an UI-spec |
|
206 |
for a components #aspect property. |
|
207 |
Here, a corresponding message is sent to myself, |
|
208 |
which ought to be defined in the application subclass. |
|
209 |
Alternatively, a subclass may redefine this method, to provide |
|
210 |
holders from a Dictionary or whatever. |
|
211 |
Typically, a valueHolder is returned there." |
|
212 |
||
213 |
^ self perform:aKey |
|
214 |
||
215 |
"/ ^ nil |
|
216 |
||
217 |
"Modified: / 27.10.1997 / 13:43:12 / cg" |
|
218 |
! |
|
219 |
||
220 |
clientFor:aKey |
|
221 |
"sent by the builder to ask for an application provided |
|
222 |
subcanvas's application. |
|
223 |
The argument, aKey comes from an UI-spec |
|
224 |
for a subcanvas's #client property. |
|
225 |
Here, a corresponding message is sent to myself, |
|
226 |
which ought to be defined in the application subclass. |
|
227 |
Alternatively, a subclass may redefine this method, to provide |
|
228 |
appModels from a Dictionary or whatever. |
|
229 |
Typically, an applicationModel is returned there." |
|
230 |
||
231 |
^ nil |
|
232 |
||
233 |
! |
|
234 |
||
235 |
componentFor:aKey |
|
236 |
"sent by the builder to ask for an application provided |
|
237 |
component. |
|
238 |
The argument, aKey comes from an UI-spec |
|
239 |
for a viewHolders #view property. |
|
240 |
Here, a corresponding message is sent to myself, |
|
241 |
which ought to be defined in the application subclass. |
|
242 |
Alternatively, a subclass may redefine this method, to provide |
|
243 |
holders from a Dictionary or whatever. |
|
244 |
Typically, a view is returned there." |
|
245 |
||
246 |
(self respondsTo:aKey) ifTrue:[ |
|
247 |
^ self perform:aKey |
|
248 |
]. |
|
249 |
^ nil |
|
250 |
! |
|
251 |
||
252 |
labelFor:aKey |
|
253 |
"sent by the builder to ask for an application provided |
|
254 |
label for a component. |
|
255 |
The argument, aKey comes from an UI-spec |
|
256 |
for a components #label property. |
|
257 |
Here, a corresponding message is sent to myself, |
|
258 |
which ought to be defined in the application subclass. |
|
259 |
Alternatively, a subclass may redefine this method, to provide |
|
260 |
labels from a Dictionary or whatever. |
|
261 |
Typically, a string is returned there." |
|
262 |
||
263 |
(self application respondsTo:aKey) ifTrue:[ |
|
264 |
^ self application perform:aKey |
|
265 |
]. |
|
266 |
^ self application labelAt:aKey ifAbsent:nil |
|
267 |
||
268 |
! |
|
269 |
||
270 |
listFor:aKey |
|
271 |
"sent by the builder to ask for an application provided |
|
272 |
holder for a list. |
|
273 |
The argument, aKey comes from an UI-spec |
|
274 |
for a listWidgets #list property. |
|
275 |
Here, a corresponding message is sent to myself, |
|
276 |
which ought to be defined in the application subclass. |
|
277 |
Alternatively, a subclass may redefine this method, to provide |
|
278 |
holders from a Dictionary or whatever. |
|
279 |
Typically, a list-holding model (SelectionInList) is returned there." |
|
280 |
||
281 |
|app| |
|
282 |
||
283 |
(app := self application) notNil ifTrue:[ |
|
284 |
(app respondsTo:aKey) ifTrue:[ |
|
285 |
^ app perform:aKey |
|
286 |
] |
|
287 |
]. |
|
288 |
^ nil. |
|
289 |
||
290 |
"Modified: 4.3.1997 / 00:53:03 / cg" |
|
291 |
! |
|
292 |
||
293 |
menuFor:aKey |
|
294 |
"sent by the builder to ask for an application provided |
|
295 |
holder for a menu. |
|
296 |
The argument, aKey comes from an UI-spec |
|
297 |
for a widgets #menu property. |
|
298 |
Here, a corresponding message is sent to myself, |
|
299 |
which ought to be defined in the application subclass. |
|
300 |
Alternatively, a subclass may redefine this method, to provide |
|
301 |
holders from a Dictionary or whatever. |
|
302 |
Typically, a menu or a menu-holding valueHolder is returned there." |
|
303 |
||
304 |
^ self application perform:aKey |
|
305 |
||
306 |
! |
|
307 |
||
308 |
specificationFor:aKey |
|
309 |
"sent by the builder to ask for an application provided |
|
310 |
specification for a subcanvas or subspecification. |
|
311 |
The argument, aKey comes from an UI-spec |
|
312 |
for a subcanvases #specification property (minorKey). |
|
313 |
Here, a corresponding message is sent to myself, |
|
314 |
which ought to be defined in the application subclass. |
|
315 |
Alternatively, a subclass may redefine this method, to provide |
|
316 |
interfaceSpecifications from a Dictionary or whatever. |
|
317 |
Typically, an interfaceSpecification is returned there." |
|
318 |
||
1584 | 319 |
^ self |
320 |
specificationFor:aKey |
|
321 |
application:self |
|
322 |
onDevice:nil |
|
323 |
! |
|
324 |
||
325 |
specificationFor:aKey application:app onDevice:deviceOrNil |
|
326 |
"sent by the builder to ask for an application provided |
|
327 |
specification for a subcanvas or subspecification. |
|
328 |
The argument, aKey comes from an UI-spec |
|
329 |
for a subcanvases #specification property (minorKey). |
|
330 |
Here, a corresponding message is sent to myself, |
|
331 |
which ought to be defined in the application subclass. |
|
332 |
Alternatively, a subclass may redefine this method, to provide |
|
333 |
interfaceSpecifications from a Dictionary or whatever. |
|
334 |
Typically, an interfaceSpecification is returned there." |
|
335 |
||
336 |
|displayDevice displayDeviceType modifiedKey appClass| |
|
1479
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
337 |
|
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
338 |
"/ this code is so ugly... |
1584 | 339 |
"/ translate the specs name, if the display device type is different |
340 |
"/ for example, if the type is pda, the xxxSpec_pda spec will be used. |
|
341 |
displayDevice := deviceOrNil ? Screen current ? Screen default. |
|
1479
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
342 |
displayDevice notNil ifTrue:[ |
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
343 |
displayDeviceType := displayDevice deviceType. |
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
344 |
displayDeviceType notNil ifTrue:[ |
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
345 |
modifiedKey := (aKey , '_' , displayDeviceType) asSymbolIfInterned. |
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
346 |
modifiedKey notNil ifTrue:[ |
1584 | 347 |
(app respondsTo:modifiedKey) ifTrue:[ |
348 |
^ app perform:modifiedKey |
|
349 |
]. |
|
350 |
app isBehavior ifFalse:[ |
|
351 |
appClass := app application. |
|
352 |
(appClass respondsTo:modifiedKey) ifTrue:[ |
|
353 |
^ appClass perform:modifiedKey |
|
354 |
]. |
|
355 |
]. |
|
1479
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
356 |
] |
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
357 |
] |
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
358 |
]. |
1584 | 359 |
|
360 |
app isBehavior ifFalse:[ |
|
361 |
(app respondsTo:aKey) ifTrue:[ |
|
362 |
^ app perform:aKey |
|
363 |
]. |
|
364 |
appClass := app application. |
|
365 |
(appClass respondsTo:aKey) ifTrue:[ |
|
366 |
^ appClass perform:aKey |
|
367 |
]. |
|
368 |
^ app masterApplication specificationFor:aKey |
|
369 |
]. |
|
370 |
||
371 |
^ app perform:aKey |
|
1115 | 372 |
! |
373 |
||
1419 | 374 |
visualFor:aKey |
375 |
"sent by the builder to ask for an application provided |
|
376 |
image or element for a label. |
|
377 |
The argument, aKey comes from an UI-spec |
|
378 |
for a widgets #label property, if LabelIsImage is turned on. |
|
379 |
Here, a corresponding message is sent to myself, |
|
380 |
which ought to be defined in the application subclass. |
|
381 |
Alternatively, a subclass may redefine this method, to provide |
|
382 |
images from a Dictionary or whatever. |
|
383 |
Typically, an image is returned there." |
|
384 |
||
385 |
(self application respondsTo:aKey) ifTrue:[ |
|
386 |
^ self application perform:aKey |
|
387 |
]. |
|
388 |
^ self application visualAt:aKey ifAbsent:nil |
|
389 |
||
390 |
||
391 |
! ! |
|
392 |
||
393 |
!ApplicationModel class methodsFor:'change & update'! |
|
394 |
||
395 |
update:something with:aParameter from:changedObject |
|
396 |
"flush resources on language changes" |
|
397 |
||
398 |
something == #Language ifTrue:[ |
|
399 |
"flush resources on language changes" |
|
400 |
self flushAllClassResources |
|
401 |
] |
|
402 |
||
403 |
"Created: 15.6.1996 / 15:13:29 / cg" |
|
404 |
! ! |
|
405 |
||
406 |
!ApplicationModel class methodsFor:'defaults'! |
|
407 |
||
408 |
defaultIcon |
|
1431 | 409 |
"default is: no icon (should be redefined by concrete class if an icon is wanted)." |
410 |
||
1419 | 411 |
^ nil |
412 |
! |
|
413 |
||
414 |
labelAt:aKey |
|
1431 | 415 |
"default is: no label (could be redefined by concrete class )." |
416 |
||
1419 | 417 |
^ nil |
418 |
! |
|
419 |
||
420 |
labelAt:aKey ifAbsent:aBlock |
|
1431 | 421 |
"default is: no label (could be redefined by concrete class )." |
422 |
||
1419 | 423 |
^ aBlock value |
424 |
! |
|
425 |
||
426 |
labelAt:aKey put:aValue |
|
427 |
"/ not yet implemented |
|
428 |
! |
|
429 |
||
430 |
labels |
|
431 |
"/ not yet implemented |
|
432 |
^ nil |
|
433 |
! |
|
434 |
||
435 |
visualAt:aKey |
|
1431 | 436 |
"default is: no visual (could be redefined by concrete class )." |
437 |
||
1419 | 438 |
^ nil |
439 |
! |
|
440 |
||
441 |
visualAt:aKey ifAbsent:aBlock |
|
1431 | 442 |
"default is: no visual (could be redefined by concrete class )." |
443 |
||
1419 | 444 |
^ aBlock value |
445 |
! |
|
446 |
||
447 |
visualAt:aKey put:aValue |
|
448 |
"/ not yet implemented |
|
449 |
! |
|
450 |
||
451 |
visuals |
|
452 |
"/ not yet implemented |
|
453 |
^ nil |
|
454 |
! ! |
|
455 |
||
456 |
!ApplicationModel class methodsFor:'queries'! |
|
457 |
||
458 |
interfaceSpecFor:aSelector |
|
459 |
"return an interface spec" |
|
460 |
||
461 |
^ UISpecification from:(self application specificationFor:aSelector) |
|
462 |
! |
|
463 |
||
464 |
isVisualStartable |
|
1427 | 465 |
"return true, if this application can be started via #open. |
466 |
(to allow start of a change browser via double-click in the browser)" |
|
1419 | 467 |
|
468 |
(self == ApplicationModel) ifTrue:[^ false "I am abstract"]. |
|
1556
388922a9c6eb
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1548
diff
changeset
|
469 |
((self respondsTo:#open) or:[self class includesSelector:#openInterface]) ifFalse:[^ false]. |
1419 | 470 |
"/ (self respondsTo:#windowSpec) ifFalse:[^ false]. |
471 |
^ true |
|
472 |
||
473 |
"Created: / 27.10.1997 / 16:38:02 / cg" |
|
474 |
"Modified: / 14.3.1998 / 16:30:50 / cg" |
|
475 |
! ! |
|
476 |
||
477 |
!ApplicationModel class methodsFor:'resources'! |
|
478 |
||
479 |
classResources |
|
480 |
"if not already loaded, get the classes resourcePack |
|
481 |
and return it" |
|
482 |
||
483 |
ClassResources isNil ifTrue:[ |
|
484 |
ClassResources := ResourcePack for:self. |
|
485 |
]. |
|
486 |
^ ClassResources |
|
487 |
! |
|
488 |
||
489 |
classResources:aResourcePack |
|
490 |
"allow setting of the classResources" |
|
491 |
||
492 |
ClassResources := aResourcePack |
|
493 |
! |
|
494 |
||
495 |
flushAllClassResources |
|
496 |
"flush all classes resource translations. |
|
497 |
Needed after a resource file / language setting has changed." |
|
498 |
||
499 |
ResourcePack flushCachedResourcePacks. |
|
500 |
self flushClassResources. |
|
501 |
self allSubclassesDo:[:aClass | |
|
502 |
aClass flushClassResources. |
|
503 |
] |
|
504 |
! |
|
505 |
||
506 |
flushClassResources |
|
507 |
"flush classes resource string translations. |
|
508 |
Needed whenever a resource file / language setting has changed" |
|
509 |
||
510 |
ClassResources := nil. |
|
511 |
! |
|
512 |
||
513 |
resources |
|
514 |
"return the applications resources - thats a ResourcePack containing |
|
515 |
language strings" |
|
516 |
||
517 |
^ self classResources |
|
518 |
||
519 |
"Created: / 19.5.1998 / 20:14:00 / cg" |
|
520 |
! |
|
521 |
||
522 |
updateClassResources |
|
523 |
"update my classResources" |
|
524 |
||
525 |
ClassResources := nil. |
|
526 |
self classResources |
|
527 |
! ! |
|
528 |
||
529 |
!ApplicationModel class methodsFor:'startup'! |
|
530 |
||
531 |
open |
|
532 |
"create an instance of the application and open its view" |
|
533 |
||
534 |
^ self new open |
|
535 |
||
536 |
" |
|
537 |
Launcher open |
|
538 |
" |
|
539 |
||
540 |
"Modified: 13.1.1997 / 20:54:50 / cg" |
|
541 |
! |
|
542 |
||
543 |
openAt:aLocation |
|
544 |
"create an instance of the application and open its view |
|
545 |
at some position." |
|
546 |
||
547 |
^ self new openAt:aLocation |
|
548 |
||
549 |
"Modified: 14.2.1997 / 20:28:41 / cg" |
|
550 |
! |
|
551 |
||
552 |
openDialogInterface:anInterfaceSymbol |
|
553 |
"create an instance of the application and open a view as |
|
554 |
specified by anInterfaceSymbol." |
|
555 |
||
556 |
^ self openDialogInterface:anInterfaceSymbol withBindings:nil |
|
557 |
||
558 |
"Modified: 5.9.1995 / 17:54:50 / claus" |
|
559 |
"Created: 14.2.1997 / 20:33:10 / cg" |
|
560 |
"Modified: 28.2.1997 / 14:07:36 / cg" |
|
561 |
! |
|
562 |
||
563 |
openDialogInterface:anInterfaceSymbol withBindings:bindings |
|
564 |
"create an instance of the application and open a view as |
|
565 |
specified by anInterfaceSymbol." |
|
566 |
||
567 |
^ self new openDialogInterface:anInterfaceSymbol withBindings:bindings |
|
568 |
||
569 |
"Modified: 5.9.1995 / 17:54:50 / claus" |
|
570 |
"Modified: 13.1.1997 / 20:55:02 / cg" |
|
571 |
"Created: 28.2.1997 / 14:07:24 / cg" |
|
572 |
! |
|
573 |
||
574 |
openDialogInterfaceSpec:anInterfaceSpec |
|
575 |
"create an instance of the application and open a view as |
|
576 |
specified by the given spec." |
|
577 |
||
578 |
^ self new |
|
579 |
openDialogInterfaceSpec:anInterfaceSpec |
|
580 |
withBindings:nil |
|
581 |
! |
|
582 |
||
583 |
openDialogInterfaceSpec:anInterfaceSpec withBindings:bindings |
|
584 |
"create an instance of the application and open a view as |
|
585 |
specified by the given spec." |
|
586 |
||
587 |
^ self new |
|
588 |
openDialogInterfaceSpec:anInterfaceSpec |
|
589 |
withBindings:bindings |
|
590 |
||
591 |
"Modified: 5.9.1995 / 17:54:50 / claus" |
|
592 |
"Modified: 13.1.1997 / 20:55:02 / cg" |
|
593 |
"Created: 28.2.1997 / 14:07:24 / cg" |
|
594 |
! |
|
595 |
||
596 |
openDialogSpec:aSpec |
|
597 |
"create an instance of the application and open a view as |
|
598 |
specified by aSpec." |
|
599 |
||
600 |
^ self openDialogSpec:aSpec withBindings:nil |
|
601 |
||
602 |
"Modified: / 5.9.1995 / 17:54:50 / claus" |
|
603 |
"Modified: / 28.2.1997 / 14:07:36 / cg" |
|
604 |
"Created: / 20.5.1998 / 20:27:08 / cg" |
|
605 |
! |
|
606 |
||
607 |
openDialogSpec:aSpec withBindings:bindings |
|
608 |
"create an instance of the application and open a view as |
|
609 |
specified by the spec." |
|
610 |
||
611 |
^ self new openDialogSpec:aSpec withBindings:bindings |
|
612 |
||
613 |
"Modified: / 5.9.1995 / 17:54:50 / claus" |
|
614 |
"Modified: / 13.1.1997 / 20:55:02 / cg" |
|
615 |
"Created: / 20.5.1998 / 20:26:37 / cg" |
|
616 |
! |
|
617 |
||
618 |
openInterface:anInterfaceSymbol |
|
619 |
"create an instance of the application and open a view as |
|
620 |
specified by anInterfaceSymbol." |
|
621 |
||
622 |
^ self new openInterface:anInterfaceSymbol |
|
623 |
||
624 |
"Modified: 5.9.1995 / 17:54:50 / claus" |
|
625 |
"Modified: 13.1.1997 / 20:55:02 / cg" |
|
626 |
! |
|
627 |
||
628 |
openInterface:anInterfaceSymbol at:aPoint |
|
629 |
"create an instance of the application and open a view as |
|
630 |
specified by anInterfaceSymbol." |
|
631 |
||
632 |
^ self new openInterface:anInterfaceSymbol at:aPoint |
|
633 |
||
634 |
"Modified: 14.2.1997 / 20:28:47 / cg" |
|
635 |
! |
|
636 |
||
637 |
openModal |
|
638 |
"create an instance of the application and open its view modal" |
|
639 |
||
640 |
^ self new openModal |
|
641 |
! |
|
642 |
||
643 |
openOn:anApplicationModel |
|
644 |
"send an open message to the argument, anApplicationModel. |
|
645 |
I dont really understand what this method is useful for ..." |
|
646 |
||
647 |
^ anApplicationModel open |
|
648 |
||
649 |
"Modified: 13.1.1997 / 20:55:05 / cg" |
|
650 |
! |
|
651 |
||
652 |
openOnDevice:aDevice |
|
653 |
"create an instance of the application and open its view |
|
654 |
on ANOTHER device. |
|
655 |
For more info, read the document on multiple display |
|
656 |
support and the documentation of the DeviceWorkstation class." |
|
657 |
||
1444 | 658 |
Screen currentScreenQuerySignal answer:aDevice |
659 |
do:[ |
|
660 |
^ (self onDevice:aDevice) open |
|
661 |
] |
|
1419 | 662 |
|
663 |
" |
|
664 |
Launcher openOnDevice:Display |
|
665 |
" |
|
666 |
||
667 |
"Modified: 13.1.1997 / 20:55:27 / cg" |
|
668 |
! |
|
669 |
||
670 |
openOnXScreenNamed:aScreenName |
|
671 |
"create an instance of the application and open its view |
|
672 |
on some X display screen. The argument aScreenName must be |
|
673 |
a valid x-display name (i.e. of the form '<host>:<screenNr>' as in 'foo:0'). |
|
674 |
For more info, read the document on multiple display |
|
675 |
support and the documentation of the DeviceWorkstation class." |
|
676 |
||
1570
5ef90b35b7d6
Changed Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
1565
diff
changeset
|
677 |
|newDevice| |
5ef90b35b7d6
Changed Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
1565
diff
changeset
|
678 |
|
5ef90b35b7d6
Changed Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
1565
diff
changeset
|
679 |
[ |
5ef90b35b7d6
Changed Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
1565
diff
changeset
|
680 |
newDevice := XWorkstation newDispatchingFor:aScreenName. |
5ef90b35b7d6
Changed Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
1565
diff
changeset
|
681 |
] on:Screen deviceOpenErrorSignal do:[:ex| |
5ef90b35b7d6
Changed Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
1565
diff
changeset
|
682 |
self warn:'Could not open display: ' , aScreenName. |
5ef90b35b7d6
Changed Workstation initialization.
Stefan Vogel <sv@exept.de>
parents:
1565
diff
changeset
|
683 |
^ self |
995
63d1b9ce554b
Avoid invoking pre/postBuild twice for subCanvases which
Claus Gittinger <cg@exept.de>
parents:
983
diff
changeset
|
684 |
]. |
1479
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
685 |
^ self openOnDevice:newDevice. |
1419 | 686 |
|
687 |
" |
|
688 |
Launcher openOnXScreenNamed:'sgi:0' |
|
689 |
Launcher openOnXScreenNamed:'foo:0' |
|
690 |
NewLauncher openOnXScreenNamed:'dawn:0' |
|
1479
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
691 |
NewLauncher openOnXScreenNamed:'bitsy:0' |
1419 | 692 |
SystemBrowser openOnXScreenNamed:'dawn:0' |
1479
c30179d243db
allow device-specific windowSpecs
Claus Gittinger <cg@exept.de>
parents:
1478
diff
changeset
|
693 |
SystemBrowser openOnXScreenNamed:'bitsy:0' |
1419 | 694 |
" |
695 |
||
696 |
"Modified: 13.1.1997 / 20:55:27 / cg" |
|
697 |
! |
|
698 |
||
699 |
openWithSpec:aSpecSymbol |
|
700 |
"ST80 compatibility: |
|
701 |
mhmh - what is the difference to #openInterface ?" |
|
702 |
||
703 |
^ self openInterface:aSpecSymbol |
|
704 |
||
705 |
"Modified: 29.8.1997 / 01:16:52 / cg" |
|
706 |
! ! |
|
707 |
||
708 |
!ApplicationModel methodsFor:'accessing'! |
|
709 |
||
710 |
application |
|
711 |
"application knows about interfaceSpecs, menuSpecs etc. |
|
712 |
Usually this is my class. |
|
713 |
This may be redefined in subclasses" |
|
714 |
||
715 |
^ self class |
|
716 |
||
717 |
"Modified: / 5.2.1998 / 00:45:21 / stefan" |
|
718 |
! |
|
719 |
||
720 |
builder |
|
721 |
"return the applications builder; this one has more information |
|
722 |
about views, components etc." |
|
723 |
||
724 |
^ builder |
|
725 |
! |
|
726 |
||
727 |
builder:aBuilder |
|
728 |
"set the applications builder. Normally, you should not set it |
|
729 |
directly, but depend on the default builder, as created when the application |
|
730 |
was created." |
|
731 |
||
732 |
builder := aBuilder |
|
733 |
! |
|
734 |
||
1602 | 735 |
componentAt:name |
736 |
^ self builder componentAt:name |
|
737 |
! |
|
738 |
||
1419 | 739 |
focusSequence |
740 |
"return a focusSequence for stepping through the applications views. |
|
741 |
The builder usually keeps track of so-called 'tabable' views. |
|
742 |
Stepping is done with the FocusNext/FocusPrevius keys, which are |
|
743 |
typically bound to Meta-CursorUp/Meta-CursorDown. |
|
744 |
(unless the focus is currently attached to a textEditing view, |
|
745 |
tabbing is also possible via the tab-key) |
|
746 |
Subclasses which do not use the builder (but instead build their view |
|
747 |
programmatically) should redefine this method to return a collection of |
|
748 |
views which defines that sequence. |
|
749 |
Notice, that the focuse sequence is asked for at the time of the tabbing |
|
750 |
(not only during startup of the view) - so dynamically adding/removing |
|
751 |
components is possible." |
|
752 |
||
753 |
builder notNil ifTrue:[ |
|
754 |
^ builder focusSequence |
|
755 |
]. |
|
756 |
^ nil |
|
757 |
||
758 |
"Modified: / 31.10.1997 / 19:11:14 / cg" |
|
759 |
! |
|
760 |
||
761 |
masterApplication |
|
762 |
"return the value of the instance variable 'masterApplication' (automatically generated)" |
|
763 |
||
1427 | 764 |
^ masterApplication |
765 |
! |
|
1419 | 766 |
|
767 |
masterApplication:something |
|
768 |
"set the value of the instance variable 'masterApplication' (automatically generated)" |
|
769 |
||
770 |
something == self ifTrue:[ |
|
771 |
self error:'an application cannot be its own masterApplication' mayProceed:true. |
|
772 |
^ self |
|
773 |
]. |
|
774 |
masterApplication := something. |
|
775 |
! |
|
776 |
||
777 |
resources |
|
778 |
"return the applications resources - thats a ResourcePack containing |
|
779 |
language strings" |
|
780 |
||
781 |
^ resources |
|
782 |
! |
|
783 |
||
784 |
resources:aResourcePack |
|
785 |
"set the applications resources - usually tis is done automatically, |
|
786 |
except for manually built dialogs" |
|
787 |
||
788 |
resources := aResourcePack |
|
789 |
! |
|
790 |
||
791 |
window |
|
792 |
"return my topWindow - or nil, if I have no window (yet)" |
|
793 |
||
794 |
|win| |
|
795 |
||
796 |
builder isNil ifTrue:[^ nil]. |
|
797 |
(win := builder window) notNil ifTrue:[ |
|
798 |
^ win |
|
799 |
]. |
|
800 |
masterApplication notNil ifTrue:[ |
|
1442
96d3aff662c3
check for masterApplication == self (to avoid endless recursion)
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
801 |
masterApplication ~~ self ifTrue:[ |
96d3aff662c3
check for masterApplication == self (to avoid endless recursion)
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
802 |
"/ is that true ? |
96d3aff662c3
check for masterApplication == self (to avoid endless recursion)
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
803 |
^ masterApplication window |
96d3aff662c3
check for masterApplication == self (to avoid endless recursion)
Claus Gittinger <cg@exept.de>
parents:
1432
diff
changeset
|
804 |
] |
1419 | 805 |
]. |
806 |
^ nil. |
|
807 |
||
808 |
"Modified: / 18.9.1998 / 15:18:19 / cg" |
|
809 |
! |
|
810 |
||
811 |
window:aTopView |
|
812 |
"set my topWindow. |
|
813 |
As a side effect, this creates a dummy builder if non has yet |
|
814 |
been built. This prevents non-GUI-Painter apps from failing later, |
|
815 |
when the builder is accessed." |
|
816 |
||
817 |
builder isNil ifTrue:[ |
|
818 |
self createBuilder |
|
819 |
]. |
|
820 |
builder window:aTopView |
|
821 |
||
822 |
"Created: 18.4.1996 / 14:55:26 / cg" |
|
823 |
! |
|
824 |
||
825 |
windowGroup |
|
826 |
"return the applications windowGroup" |
|
827 |
||
828 |
|w| |
|
829 |
||
830 |
builder notNil ifTrue:[ |
|
831 |
(w := builder window) notNil ifTrue:[ |
|
832 |
^ w windowGroup |
|
833 |
]. |
|
834 |
]. |
|
835 |
masterApplication notNil ifTrue:[ |
|
836 |
^ masterApplication windowGroup |
|
837 |
]. |
|
838 |
^ nil |
|
839 |
||
840 |
"Modified: / 7.9.1998 / 23:37:00 / cg" |
|
841 |
! ! |
|
842 |
||
843 |
!ApplicationModel methodsFor:'binding access'! |
|
844 |
||
845 |
actionFor:aKey |
|
846 |
"sent by the builder to ask for an actionBlock for |
|
847 |
a Button. The argument, aKey comes from an UI-spec |
|
848 |
for a buttons #action property. |
|
849 |
Here, a corresponding message is sent to myself, |
|
850 |
which ought to be defined in the application subclass. |
|
851 |
Alternatively, a subclass may redefine this method, to provide |
|
852 |
actionBlocks from a Dictionary or whatever. |
|
853 |
Typically, a block is returned there." |
|
854 |
||
855 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
856 |
^ [self perform:aKey] "/ could use: MessageSend receiver:self selector:aKey |
|
857 |
]. |
|
858 |
^ masterApplication actionFor:aKey |
|
859 |
||
860 |
"Modified: / 28.10.1997 / 20:34:51 / cg" |
|
861 |
! |
|
862 |
||
863 |
actionFor:aKey withValue:aValue |
|
864 |
"sent by the builder to ask for an actionBlock for |
|
865 |
a Button which passes a value. |
|
866 |
The argument, aKey comes from an UI-spec for a buttons #action property. |
|
867 |
Here, a corresponding message is sent to myself, |
|
868 |
which ought to be defined in the application subclass. |
|
869 |
Alternatively, a subclass may redefine this method, to provide |
|
870 |
actionBlocks from a Dictionary or whatever. |
|
871 |
Typically, a block is returned there." |
|
872 |
||
873 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
874 |
^ [self perform:aKey with:aValue] |
|
875 |
]. |
|
876 |
^ masterApplication actionFor:aKey withValue:aValue |
|
877 |
! |
|
878 |
||
879 |
aspectFor:aKey |
|
880 |
"sent by the builder to ask for an aspect (a data model). |
|
881 |
The argument, aKey comes from an UI-spec |
|
882 |
for a components #aspect property. |
|
883 |
Here, a corresponding message is sent to myself, |
|
884 |
which ought to be defined in the application subclass. |
|
885 |
Alternatively, a subclass may redefine this method, to provide |
|
886 |
holders from a Dictionary or whatever. |
|
887 |
Typically, a valueHolder is returned there." |
|
888 |
||
889 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
890 |
^ self perform:aKey |
|
891 |
]. |
|
892 |
^ masterApplication aspectFor:aKey |
|
893 |
||
894 |
"Modified: / 18.6.1998 / 20:33:23 / cg" |
|
895 |
! |
|
896 |
||
897 |
clientFor:aKey |
|
898 |
"sent by the builder to ask for an application provided |
|
899 |
subcanvas's application. |
|
900 |
The argument, aKey comes from an UI-spec |
|
901 |
for a subcanvas's #client property. |
|
902 |
Here, a corresponding message is sent to myself, |
|
903 |
which ought to be defined in the application subclass. |
|
904 |
Alternatively, a subclass may redefine this method, to provide |
|
905 |
appModels from a Dictionary or whatever. |
|
906 |
Typically, an applicationModel is returned there." |
|
907 |
||
908 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
909 |
^ self perform:aKey |
|
910 |
]. |
|
911 |
^ masterApplication clientFor:aKey |
|
912 |
||
913 |
"Modified: / 18.6.1998 / 20:33:30 / cg" |
|
914 |
! |
|
915 |
||
916 |
componentFor:aKey |
|
917 |
"sent by the builder to ask for an application provided |
|
918 |
component. |
|
919 |
The argument, aKey comes from an UI-spec |
|
920 |
for a viewHolders #view property. |
|
921 |
Here, a corresponding message is sent to myself, |
|
922 |
which ought to be defined in the application subclass. |
|
923 |
Alternatively, a subclass may redefine this method, to provide |
|
924 |
holders from a Dictionary or whatever. |
|
925 |
Typically, a view is returned there." |
|
926 |
||
927 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
928 |
^ self perform:aKey |
|
929 |
]. |
|
930 |
^ masterApplication componentFor:aKey |
|
931 |
||
932 |
"Modified: / 18.6.1998 / 20:33:36 / cg" |
|
933 |
! |
|
934 |
||
1622
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
935 |
flyByHelpSpec |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
936 |
"activeHelp interface: return some short help text for a widget component" |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
937 |
|
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
938 |
^ self class flyByHelpSpec |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
939 |
! |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
940 |
|
1538 | 941 |
flyByHelpTextFor:aComponent |
942 |
"activeHelp interface: return some short help text for a widget component" |
|
943 |
||
944 |
|key cls| |
|
945 |
||
946 |
builder notNil ifTrue:[ |
|
947 |
cls := self class. |
|
948 |
||
949 |
(cls respondsTo:#flyByHelpSpec) ifTrue:[ |
|
950 |
(key := builder helpKeyFor:aComponent) notNil ifTrue:[ |
|
951 |
^ self flyByHelpTextForKey:key |
|
952 |
] |
|
953 |
] |
|
954 |
]. |
|
955 |
masterApplication notNil ifTrue:[ |
|
956 |
^ masterApplication flyByHelpTextFor:aComponent |
|
957 |
]. |
|
958 |
^ nil |
|
959 |
||
960 |
"Modified: / 31.7.1998 / 23:03:10 / cg" |
|
961 |
! |
|
962 |
||
963 |
flyByHelpTextForKey:aKey |
|
964 |
"flyByHelp interface: return some short help text for a key |
|
965 |
key is the symbol associated with some widget or menu item. |
|
966 |
(from my flyByHelpSpec); return a language variant (if available)" |
|
967 |
||
968 |
|cls helpText| |
|
969 |
||
1622
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
970 |
helpText := (self flyByHelpSpec) at:aKey ifAbsent:nil. |
1538 | 971 |
helpText isNil ifTrue:[ |
972 |
masterApplication notNil ifTrue:[ |
|
973 |
helpText := masterApplication flyByHelpTextForKey:aKey |
|
974 |
] |
|
975 |
]. |
|
976 |
||
977 |
"/ translate. |
|
978 |
resources notNil ifTrue:[ |
|
979 |
^ resources string:helpText |
|
980 |
]. |
|
981 |
^ helpText |
|
982 |
||
983 |
"Modified: / 4.2.2000 / 15:30:16 / cg" |
|
984 |
! |
|
985 |
||
1622
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
986 |
helpSpec |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
987 |
"activeHelp interface: return some short help text for a widget component" |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
988 |
|
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
989 |
^ self class helpSpec |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
990 |
! |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
991 |
|
1419 | 992 |
helpTextFor:aComponent |
993 |
"activeHelp interface: return some help text for a widget component" |
|
994 |
||
1622
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
995 |
|key| |
1419 | 996 |
|
997 |
builder notNil ifTrue:[ |
|
1622
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
998 |
(key := builder helpKeyFor:aComponent) notNil ifTrue:[ |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
999 |
^ self helpTextForKey:key |
1419 | 1000 |
] |
1001 |
]. |
|
1002 |
masterApplication notNil ifTrue:[ |
|
1003 |
^ masterApplication helpTextFor:aComponent |
|
1004 |
]. |
|
1005 |
^ nil |
|
1006 |
||
1007 |
"Modified: / 31.7.1998 / 23:03:10 / cg" |
|
1008 |
! |
|
1009 |
||
1010 |
helpTextForKey:aKey |
|
1011 |
"activeHelp interface: return some help text for a key |
|
1012 |
key is the symbol associated with some widget or menu item. |
|
1013 |
(from my helpSpec); return a language variant (if available)" |
|
1014 |
||
1622
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
1015 |
|helpText| |
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
1016 |
|
6673cc18b194
helpSpec and flyByHelpSpec on instance side
Claus Gittinger <cg@exept.de>
parents:
1602
diff
changeset
|
1017 |
helpText := (self helpSpec) at:aKey ifAbsent:nil. |
1538 | 1018 |
helpText isNil ifTrue:[ |
1019 |
masterApplication notNil ifTrue:[ |
|
1020 |
helpText := masterApplication helpTextForKey:aKey |
|
1021 |
]. |
|
1419 | 1022 |
]. |
1538 | 1023 |
|
1419 | 1024 |
"/ translate. |
1025 |
resources notNil ifTrue:[ |
|
1026 |
^ resources string:helpText |
|
1027 |
]. |
|
1028 |
^ helpText |
|
1029 |
||
1030 |
"Modified: / 4.2.2000 / 15:30:16 / cg" |
|
657 | 1031 |
! |
1032 |
||
1419 | 1033 |
labelFor:aKey |
1034 |
"sent by the builder to ask for an application provided |
|
1035 |
label for a component. |
|
1036 |
The argument, aKey comes from an UI-spec |
|
1037 |
for a components #label property. |
|
1038 |
Here, a corresponding message is sent to myself, |
|
1039 |
which ought to be defined in the application subclass. |
|
1040 |
Alternatively, a subclass may redefine this method, to provide |
|
1041 |
labels from a Dictionary or whatever. |
|
1042 |
Typically, a string is returned there." |
|
1043 |
||
1044 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
1045 |
^ self perform:aKey |
|
1046 |
]. |
|
1047 |
^ masterApplication labelFor:aKey |
|
1048 |
||
1049 |
"Modified: / 18.6.1998 / 20:33:42 / cg" |
|
1050 |
! |
|
1051 |
||
1052 |
listFor:aKey |
|
1053 |
"sent by the builder to ask for an application provided |
|
1054 |
holder for a list (for example, a popUpLists list). |
|
1055 |
The argument, aKey comes from an UI-spec |
|
1056 |
for a listWidgets #list property. |
|
1057 |
Here, a corresponding message is sent to myself, |
|
1058 |
which ought to be defined in the application subclass. |
|
1059 |
Alternatively, a subclass may redefine this method, to provide |
|
1060 |
holders from a Dictionary or whatever. |
|
1061 |
Typically, a list-holding model (SelectionInList) is returned there. |
|
1062 |
If the instance does not provide a value, a corresponding aspect |
|
1063 |
is asked for. If that fails as well, the app class is asked as a last |
|
1064 |
chance." |
|
1065 |
||
1066 |
|a| |
|
1067 |
||
1068 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
1069 |
^ self perform:aKey |
|
1070 |
]. |
|
1071 |
a := self aspectFor:aKey. |
|
1072 |
a notNil ifTrue:[ |
|
1073 |
^ a |
|
1074 |
]. |
|
1075 |
^ self application listFor:aKey |
|
1076 |
||
1077 |
"Modified: / 18.6.1998 / 20:33:50 / cg" |
|
1078 |
! |
|
1079 |
||
1080 |
menuFor:aKey |
|
1081 |
"sent by the builder to ask for an application provided |
|
1082 |
holder for a menu. |
|
1083 |
The argument, aKey comes from an UI-spec |
|
1084 |
for a widgets #menu property. |
|
1085 |
Here, a corresponding message is sent to myself, |
|
1086 |
which ought to be defined in the application subclass. |
|
1087 |
Alternatively, a subclass may redefine this method, to provide |
|
1088 |
holders from a Dictionary or whatever. |
|
1089 |
Typically, a menu or a menu-holding valueHolder is returned there." |
|
1090 |
||
1091 |
(self selfResponsibleFor:aKey) ifTrue:[ |
|
1092 |
^ self perform:aKey |
|
1093 |
]. |
|
1094 |
^ masterApplication menuFor:aKey |
|
1095 |
||
1096 |
"Modified: / 18.6.1998 / 20:33:56 / cg" |
|
1097 |
! |
|
1098 |
||
1099 |
specificationFor:aKey |
|
1100 |
"sent by the builder to ask for an application provided |
|
1101 |
specification for a subcanvas or subspecification. |
|
1102 |
The argument, aKey comes from an UI-spec |
|
1103 |
for a subcanvases #specification property (minorKey). |
|
1104 |
Here, a corresponding message is sent to myself, |
|
1105 |
which ought to be defined in the application subclass. |
|
1106 |
Alternatively, a subclass may redefine this method, to provide |
|
1107 |
interfaceSpecifications from a Dictionary or whatever. |
|
1108 |
Typically, an interfaceSpecification is returned there." |
|
1109 |
||
1584 | 1110 |
^ ApplicationModel |
1111 |
specificationFor:aKey |
|
1112 |
application:self |
|
1113 |
onDevice:(self graphicsDevice) |
|
1419 | 1114 |
! |
1115 |
||
1116 |
visualFor:aKey |
|
1117 |
"sent by the builder to ask for an application provided |
|
1118 |
image or element for a label. |
|
1119 |
The argument, aKey comes from an UI-spec |
|
1120 |
for a widgets #label property, if LabelIsImage is turned on. |
|
1121 |
Here, a corresponding message is sent to myself, |
|
1122 |
which ought to be defined in the application subclass. |
|
1123 |
Alternatively, a subclass may redefine this method, to provide |
|
1124 |
images from a Dictionary or whatever. |
|
1125 |
Typically, an image is returned there." |
|
1126 |
||
1127 |
^ self application visualFor:aKey |
|
1128 |
||
1129 |
! ! |
|
1130 |
||
1131 |
!ApplicationModel methodsFor:'change & update'! |
|
1132 |
||
1133 |
delayedUpdate:something with:aParameter from:changedObject |
|
1134 |
"support for delayed updates - |
|
1135 |
subclasses which invoke #enqueueDelayedUpdate:with:from: (from #update:with:from:) |
|
1136 |
must also redefine this method, and perform the actual update there." |
|
1137 |
||
1138 |
^ self |
|
1139 |
! |
|
1140 |
||
1141 |
enqueueDelayedUpdate:something with:aParameter from:changedObject |
|
1142 |
"support for delayed updates - to be invoked from a concrete classes |
|
1143 |
#update:with:from: method. |
|
1144 |
This will enqueue a delayed update, and resend #delayedUpdate:with:from: |
|
1145 |
whenever the receiver is handling events. |
|
1146 |
Especially useful, if many updates arrive at high frequency, to avoid |
|
1147 |
multiple redraws." |
|
1148 |
||
1149 |
^ self |
|
1150 |
enqueueMessage:#delayedUpdate:with:from: |
|
1151 |
for:self |
|
1152 |
arguments:(Array |
|
1153 |
with:something |
|
1154 |
with:aParameter |
|
1155 |
with:changedObject). |
|
1156 |
||
1157 |
"Modified: / 26.2.2000 / 18:01:44 / cg" |
|
1158 |
! |
|
1159 |
||
1160 |
enqueueMessage:selector for:someone arguments:argList |
|
1161 |
"enqueue a message to be sent to myself later, when my process |
|
1162 |
is back in its eventLoop. Also, filter duplicates. |
|
1163 |
This is useful, to buffer redraws and avoid flicker due to multiple |
|
1164 |
redraws (especially in browsers, when reacting on changeMessages resulting |
|
1165 |
from changes made in other browsers)" |
|
1166 |
||
1167 |
|window sensor| |
|
1168 |
||
1169 |
(window := self window) notNil ifTrue:[ |
|
1170 |
sensor := window sensor. |
|
1171 |
]. |
|
1172 |
sensor isNil ifTrue:[ |
|
1173 |
"/ already closed, or not yet open |
|
1174 |
||
1175 |
^ someone perform:selector withArguments:argList. |
|
1176 |
]. |
|
1177 |
||
1417 | 1178 |
"/ |
1419 | 1179 |
"/ if such a message is already in the queue, ignore it. |
1180 |
"/ Otherwise push it as an event, to be handled when my thread is |
|
1181 |
"/ back in the event loop. |
|
1182 |
"/ |
|
1183 |
(sensor |
|
1184 |
hasEvent:selector |
|
1185 |
for:someone |
|
1186 |
withArguments:argList) ifTrue:[ |
|
1187 |
^ self |
|
1188 |
]. |
|
1189 |
sensor |
|
1190 |
pushUserEvent:selector |
|
1191 |
for:someone |
|
1192 |
withArguments:argList |
|
1193 |
||
1194 |
"Modified: / 5.2.2000 / 00:01:54 / cg" |
|
1195 |
"Created: / 26.2.2000 / 18:01:31 / cg" |
|
1196 |
! ! |
|
1197 |
||
1198 |
!ApplicationModel methodsFor:'component manipulations'! |
|
1199 |
||
1200 |
components:aSymbolOrArray do:aBlock |
|
1201 |
"evaluate aBlock for all components listed aSymbolOrArray." |
|
1202 |
||
1203 |
|coll| |
|
1204 |
||
1205 |
aSymbolOrArray isSymbol ifTrue:[ |
|
1206 |
"/ a single components name |
|
1207 |
coll := Array with:aSymbolOrArray |
|
1208 |
] ifFalse:[ |
|
1209 |
coll := aSymbolOrArray |
|
1210 |
]. |
|
1211 |
coll do:[:aSymbol | |
|
1212 |
|component| |
|
1213 |
||
1214 |
(component := self componentFor:aSymbol) isNil ifFalse:[ |
|
1215 |
aBlock value:component |
|
1216 |
] |
|
1217 |
] |
|
1218 |
||
1219 |
"Modified: 26.3.1997 / 16:23:14 / cg" |
|
1220 |
! |
|
1221 |
||
1222 |
disable:aSymbolOrArray |
|
1223 |
"disable the components whose id's are aSymbolOrArray." |
|
1224 |
||
1225 |
self components:aSymbolOrArray do:[:comp | comp disable] |
|
1226 |
||
1227 |
"Modified: 14.2.1997 / 17:32:09 / cg" |
|
1228 |
! |
|
1229 |
||
1230 |
enable:aSymbolOrArray |
|
1231 |
"enables the component(s) identified by aSymbolOrArray." |
|
1232 |
||
1233 |
self components:aSymbolOrArray do:[:comp | comp enable] |
|
1234 |
||
1235 |
"Modified: 14.2.1997 / 17:32:19 / cg" |
|
1236 |
! |
|
1237 |
||
1238 |
invalidate:aSymbolOrArray |
|
1239 |
"invalidates the component(s) identified by aSymbolOrArray." |
|
1240 |
||
1241 |
self components:aSymbolOrArray do:[:comp | comp invalidate] |
|
1242 |
||
1243 |
"Modified: 14.2.1997 / 17:32:28 / cg" |
|
1244 |
! |
|
1245 |
||
1246 |
makeInvisible:aSymbolOrArray |
|
1247 |
"makes the components whose id's are aSymbolOrArray invisible" |
|
1248 |
||
1249 |
self components:aSymbolOrArray do:[:comp | comp beInvisible] |
|
1250 |
||
1251 |
"Modified: 14.2.1997 / 17:32:42 / cg" |
|
1252 |
! |
|
1253 |
||
1254 |
makeReadOnly:aSymbolOrArray |
|
1255 |
"make all components identified by aSymbolOrArray read only |
|
1256 |
(for editText components)." |
|
1257 |
||
1258 |
self components:aSymbolOrArray do:[:comp | comp readOnly:true] |
|
1259 |
||
1260 |
"Modified: 14.2.1997 / 17:36:22 / cg" |
|
1261 |
! |
|
1262 |
||
1263 |
makeVisible:aSymbolOrArray |
|
1264 |
"makes the components whose id's are aSymbolOrArray visible" |
|
1265 |
||
1266 |
self components:aSymbolOrArray do:[:comp | comp beVisible] |
|
1267 |
||
1268 |
"Modified: 14.2.1997 / 17:32:52 / cg" |
|
1269 |
! |
|
1270 |
||
1271 |
makeWritable:aSymbolOrArray |
|
1272 |
"make all components identified by aSymbolOrArray writable |
|
1273 |
(for editText components)." |
|
1274 |
||
1275 |
self components:aSymbolOrArray do:[:comp | comp readOnly:false] |
|
1276 |
||
1277 |
"Created: 14.2.1997 / 17:36:17 / cg" |
|
1278 |
! ! |
|
1279 |
||
1280 |
!ApplicationModel methodsFor:'copying'! |
|
1281 |
||
1282 |
postCopy |
|
1283 |
builder := device := nil. |
|
1284 |
||
1285 |
"Created: / 19.4.1998 / 11:44:44 / cg" |
|
1286 |
! ! |
|
1287 |
||
1288 |
!ApplicationModel methodsFor:'drag & drop'! |
|
1289 |
||
1290 |
canDrop:aCollectionOfDropObjects in:aComponent |
|
1291 |
"drop manager asked if a drop is possible |
|
1292 |
- should be redefined by apps which can do it, to return true" |
|
1293 |
||
1294 |
^ false |
|
1295 |
||
1296 |
"Modified: 11.4.1997 / 12:42:47 / cg" |
|
1297 |
! |
|
1298 |
||
1299 |
drop:aCollectionOfDropObjects in:aComponent at:aPoint |
|
1300 |
"drop manager wants to drop. |
|
1301 |
This is ony sent, if #canDrop:in: returned true. |
|
1302 |
Must be redefined in apps which return true to #canDrop." |
|
1303 |
||
1304 |
self subclassResponsibility |
|
1305 |
||
1306 |
"Modified: 11.4.1997 / 12:43:19 / cg" |
|
1307 |
! ! |
|
1308 |
||
1309 |
!ApplicationModel methodsFor:'easy bindings'! |
|
1310 |
||
1311 |
registerInterestIn:aValueModel using:aSelectorOrArray |
|
1312 |
"Register interest in a change in aValueModel using information in aSelectorOrArray. |
|
1313 |
aSelectorOrArray can be one of three things: |
|
1314 |
||
1315 |
1) nil in which case no interest is registered |
|
1316 |
2) a selector in which case the receiver is understood to be self |
|
1317 |
3) an Array in which case the size is two where the first element is the |
|
1318 |
message to be sent and the second element is the receiver." |
|
1319 |
||
1320 |
aSelectorOrArray isNil ifTrue:[^ aValueModel]. |
|
1321 |
||
1322 |
(aSelectorOrArray isArray) ifTrue:[ |
|
1323 |
aValueModel onChangeSend:(aSelectorOrArray at:1) to:(aSelectorOrArray at:2) |
|
1324 |
] ifFalse: [ |
|
1325 |
aValueModel onChangeSend:aSelectorOrArray to:self |
|
1326 |
]. |
|
1327 |
^aValueModel |
|
1328 |
||
1329 |
"Modified: / 31.10.1997 / 18:19:44 / cg" |
|
980
3764f680134d
allow subclass to redefine subCanvas-pre/postBuilds;
Claus Gittinger <cg@exept.de>
parents:
978
diff
changeset
|
1330 |
! |
3764f680134d
allow subclass to redefine subCanvas-pre/postBuilds;
Claus Gittinger <cg@exept.de>
parents:
978
diff
changeset
|
1331 |
|
1419 | 1332 |
valueHolderFor:aSelector initialValue:anObject |
1333 |
"Return a ValueHolder on anObject." |
|
1334 |
||
1335 |
^ self valueHolderFor:aSelector initialValue:anObject changeMessage:nil |
|
1336 |
||
1337 |
||
1338 |
! |
|
1339 |
||
1340 |
valueHolderFor:aSelector initialValue:anObject changeMessage:aSelectorOrArrayOrNil |
|
1341 |
"Return a ValueHolder on anObject. aSelectorOrArrayOrNil is the change information |
|
1342 |
for the ValueHolder. This argument is either a Symbol or an Array of two elements. |
|
1343 |
If it is a Symbol, then it is the change message and the interested object is understood |
|
1344 |
to be the reciever. If it is an Array, then the first element is the change message and |
|
1345 |
the second element is the interested object. " |
|
1346 |
||
1347 |
|holder| |
|
1348 |
||
1349 |
(builder bindings includesKey:aSelector) ifFalse:[ |
|
1350 |
holder := ValueHolder with:anObject. |
|
1351 |
builder aspectAt:aSelector put:holder. |
|
1352 |
aSelectorOrArrayOrNil notNil ifTrue:[ |
|
1353 |
^ self registerInterestIn:holder using:aSelectorOrArrayOrNil |
|
1354 |
]. |
|
1355 |
^ holder |
|
1356 |
]. |
|
1357 |
^ builder aspectAt:aSelector |
|
1358 |
||
1359 |
"Modified: / 21.5.1998 / 03:31:28 / cg" |
|
1360 |
! ! |
|
1361 |
||
1362 |
!ApplicationModel methodsFor:'help'! |
|
1363 |
||
1526
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1364 |
aboutImage |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1365 |
"bitmap image or nil for an about box for this application." |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1366 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1367 |
^ self class defaultIcon |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1368 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1369 |
"Modified: / 13.11.2001 / 12:32:44 / cg" |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1370 |
! |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1371 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1372 |
aboutThisApplicationLabel |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1373 |
"label for an about box for this application." |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1374 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1375 |
^ 'About This Application' |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1376 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1377 |
"Modified: / 13.11.2001 / 12:29:53 / cg" |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1378 |
! |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1379 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1380 |
aboutThisApplicationText |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1381 |
"text for an about box for this application." |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1382 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1383 |
|rev myClass clsRev msg| |
1419 | 1384 |
|
1385 |
rev := ''. |
|
1386 |
myClass := self class. |
|
1387 |
||
1388 |
(clsRev := myClass revision) notNil ifTrue: [rev := ' (rev: ', clsRev printString, ')']. |
|
1389 |
||
1390 |
msg := '\' withCRs , myClass name asBoldText, rev. |
|
1526
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1391 |
^ msg |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1392 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1393 |
"Created: / 13.11.2001 / 12:28:36 / cg" |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1394 |
! |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1395 |
|
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1396 |
openAboutThisApplication |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1397 |
"opens an about box for this application. |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1398 |
Can be specialized by redefining #aboutThisApplicationText |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1399 |
and #aboutThisApplicationLabel" |
02941e80a146
refactored aboutBox setup for easier subclassing
Claus Gittinger <cg@exept.de>
parents:
1523
diff
changeset
|
1400 |
|
1531 | 1401 |
Dialog |
1402 |
about:(resources string:self aboutThisApplicationText) |
|
1403 |
label:(resources string:self aboutThisApplicationLabel) |
|
1404 |
icon:self aboutImage |
|
1405 |
||
1406 |
"Modified: / 17.11.2001 / 23:05:52 / cg" |
|
1419 | 1407 |
! |
1408 |
||
1409 |
openHelpViewOnFile:pathToHelpText |
|
1410 |
"open a help viewer (as opened by the help buttons). |
|
1411 |
The argument is a relative path within the help directory |
|
1412 |
(but a file under the current directory is tried first)" |
|
1413 |
||
1414 |
self withWaitCursorDo:[ |
|
1415 |
HTMLDocumentView openFullOnHelpFile:pathToHelpText |
|
1416 |
] |
|
1417 |
||
1418 |
! |
|
1419 |
||
1420 |
showActiveHelp:aHelpText for:view |
|
1421 |
"This is invoked from the activeHelp event listener, to display some popup-help |
|
1422 |
for a component. If false is returned, the help manager will pop up |
|
1423 |
some active help bubble; if true is returned, it will assume that the |
|
1424 |
help text has been already displayed and will not do any further actions. |
|
1425 |
Here, we accept the help text, and push an event into out own input |
|
1426 |
queue, so that the help text will be displayed asyncronously by myself, |
|
1427 |
vis the #showHelp:for: method. |
|
1428 |
This can be redefined in concrete classes to handle active help differently." |
|
1429 |
||
1430 |
|wg mySensor| |
|
1431 |
||
1432 |
self showingHelp ifFalse: [ |
|
1433 |
^ true |
|
1434 |
]. |
|
1435 |
||
1436 |
"/ masterApplication notNil ifTrue:[ |
|
1437 |
"/ (masterApplication showActiveHelp:aHelpText for:view) ifTrue:[ |
|
1438 |
"/ ^ true |
|
1439 |
"/ ] |
|
1440 |
"/ ]. |
|
1441 |
||
1442 |
"/ NEW: push it into the event queue, to have it displayed |
|
1443 |
"/ syncronously with other events. |
|
1444 |
"/ (also any errors are reported as occurring in my context; |
|
1445 |
"/ instead of occurring in the activeHelp context). |
|
1446 |
||
1447 |
(wg := self windowGroup) notNil ifTrue:[ |
|
1448 |
mySensor := wg sensor. |
|
1449 |
mySensor notNil ifTrue:[ |
|
1450 |
mySensor flushEventsFor:self withType:#showHelp:for:. |
|
1451 |
mySensor |
|
1452 |
pushUserEvent:#showHelp:for: for:self |
|
1453 |
withArguments:(Array with:aHelpText with:view). |
|
1454 |
^ true |
|
1455 |
] |
|
1456 |
]. |
|
1457 |
||
1458 |
"/ mhmh - can this happen ? |
|
1459 |
||
1460 |
^ true |
|
1461 |
||
1462 |
"Modified: / 21.8.1998 / 16:00:37 / cg" |
|
1463 |
! |
|
1464 |
||
1465 |
showHelp:aHelpText for:view |
|
1466 |
"actual method which is supposed to display the help text. |
|
1467 |
Should be redefined in concrete classes, to put the help text |
|
1468 |
into some info label, or the windows title bar. |
|
1469 |
Here, the help text is ignored." |
|
1470 |
||
1471 |
masterApplication notNil ifTrue:[ |
|
1472 |
masterApplication showHelp:aHelpText for:view |
|
1473 |
]. |
|
1474 |
||
1475 |
"Modified: / 31.7.1998 / 19:13:59 / cg" |
|
1476 |
! |
|
1477 |
||
1478 |
showingHelp |
|
1479 |
"return true, if the activeHelp manager should invoke my #showHelp:for: |
|
1480 |
method, when the mouse pointer is moved over my widgets. |
|
1481 |
The default here is true, however, the #showHelp:for: methods are empty. |
|
1482 |
These should be redefined to put the help text into some info label, |
|
1483 |
or into the views title bar. |
|
1484 |
You may also redefine the showingHelp/showingHelp: methods, to |
|
1485 |
remember the flag setting." |
|
1486 |
||
1487 |
^ true |
|
1488 |
||
1489 |
"Modified: / 31.7.1998 / 17:55:31 / cg" |
|
1490 |
! ! |
|
1491 |
||
1492 |
!ApplicationModel methodsFor:'initialization'! |
|
1493 |
||
1494 |
addTopViewsToCurrentProject |
|
1495 |
"add all of my topViews to the current projects list of views. |
|
1496 |
This allows hiding views on a per-project basis. |
|
1497 |
Applications which do not want to be switched with projects |
|
1498 |
(such as the Launcher), may redefine this to a noop." |
|
1499 |
||
1500 |
(self windowGroup topViews ? #()) do:[:aView | |
|
1501 |
aView addToCurrentProject |
|
1502 |
] |
|
1503 |
||
1504 |
"Modified: 17.1.1997 / 19:43:39 / cg" |
|
1505 |
! |
|
1506 |
||
1507 |
basicInitialize |
|
1508 |
"initialize the application. |
|
1509 |
Since ST-80 applications seem commonly to redefine #initialize |
|
1510 |
without doing a super initialize, the real initialization is |
|
1511 |
done here ..." |
|
1512 |
||
1454 | 1513 |
Screen notNil ifTrue:[ |
1514 |
device := Screen current. |
|
1515 |
]. |
|
1419 | 1516 |
|
1517 |
"claus: I wanted to delay the creation & assignment of the |
|
1518 |
builder till later, to allow setting to another builder. |
|
1519 |
however, some ST-80 code accesses the builder right after instance |
|
1520 |
creation ..." |
|
1521 |
||
1522 |
"/ " |
|
1523 |
"/ Create a windowBuilder to have someone around which |
|
1524 |
"/ understands the builder protocol. Since UIBuilder is not present |
|
1525 |
"/ in all systems, this allows operation without one (unless a spec |
|
1526 |
"/ is read later ...) |
|
1527 |
"/ " |
|
1528 |
||
1529 |
"/ changed - cg; create the builder later. |
|
1530 |
"/ some apps (RefactoringBrowser) depend on this being set |
|
1531 |
"/ late. |
|
1532 |
||
1533 |
"/ builder := self builderClass new. |
|
1534 |
"/ builder notNil ifTrue:[builder application:self]. |
|
1535 |
resources := self class classResources. |
|
1536 |
||
1537 |
"Modified: / 20.6.1998 / 11:53:36 / cg" |
|
1538 |
! |
|
1539 |
||
1540 |
initialize |
|
1541 |
"nothing done here; |
|
1542 |
but can be redefined in concrete applications" |
|
1543 |
! |
|
1544 |
||
1545 |
setDevice:aDevice |
|
1546 |
"set the device (i.e. some Screen), where the application |
|
1547 |
shall open its view(s). |
|
1548 |
The default device (if not set here) will be the current screen." |
|
1549 |
||
1550 |
device := aDevice |
|
1551 |
||
1552 |
"Created: 5.7.1996 / 12:01:40 / cg" |
|
1553 |
"Modified: 17.1.1997 / 19:44:09 / cg" |
|
1554 |
! ! |
|
1555 |
||
1556 |
!ApplicationModel methodsFor:'misc'! |
|
1557 |
||
1558 |
information:aString |
|
1559 |
"like Objects information, but translates the string via the |
|
1560 |
resourcePack, thus giving a translated string automatically" |
|
1561 |
||
1562 |
super information:(resources string:aString) withCRs |
|
1563 |
||
1564 |
"Created: / 20.5.1998 / 03:48:43 / cg" |
|
1565 |
! |
|
1566 |
||
1567 |
restoreCursors |
|
1568 |
"restore the original cursors in all of my views" |
|
1569 |
||
1570 |
^ self window windowGroup restoreCursors |
|
1571 |
||
1572 |
"Created: 1.6.1996 / 17:01:24 / cg" |
|
1573 |
! |
|
1574 |
||
1575 |
showCursor:aCursor |
|
1576 |
"set all of my views cursor to aCursor. |
|
1577 |
It can be restored with #restoreCursor." |
|
1578 |
||
1579 |
^ self window windowGroup showCursor:aCursor |
|
1580 |
||
1581 |
"Created: 1.6.1996 / 17:01:09 / cg" |
|
1582 |
! |
|
1583 |
||
1584 |
warn:aString |
|
1585 |
"like Objects warn, but translates the string via the |
|
1586 |
resourcePack, thus giving a translated string automatically" |
|
1587 |
||
1527 | 1588 |
|s| |
1589 |
||
1590 |
resources isNil ifTrue:[ |
|
1591 |
"/ mhmh an early warning ... |
|
1592 |
s := aString |
|
1593 |
] ifFalse:[ |
|
1594 |
s := resources string:aString |
|
1595 |
]. |
|
1596 |
super warn:s withCRs |
|
1419 | 1597 |
|
1598 |
"Created: / 20.5.1998 / 01:14:52 / cg" |
|
1527 | 1599 |
"Modified: / 13.11.2001 / 20:10:12 / cg" |
1419 | 1600 |
! |
1601 |
||
1602 |
warn:aString with:arg |
|
1603 |
"like Objects warn, but translates the string via the |
|
1604 |
resourcePack, thus giving a translated string automatically" |
|
1605 |
||
1606 |
super warn:(resources string:aString with:arg) withCRs |
|
1607 |
||
1608 |
! |
|
1609 |
||
1610 |
warn:aString with:arg1 with:arg2 |
|
1611 |
"like Objects warn, but translates the string via the |
|
1612 |
resourcePack, thus giving a translated string automatically" |
|
1613 |
||
1614 |
super warn:(resources string:aString with:arg1 with:arg2) withCRs |
|
1615 |
||
1616 |
! |
|
1617 |
||
1618 |
warn:aString with:arg1 with:arg2 with:arg3 |
|
1619 |
"like Objects warn, but translates the string via the |
|
1620 |
resourcePack, thus giving a translated string automatically" |
|
1621 |
||
1622 |
super warn:(resources string:aString with:arg1 with:arg2 with:arg3) withCRs |
|
1623 |
||
1624 |
! |
|
1625 |
||
1626 |
warn:aString with:arg1 with:arg2 with:arg3 with:arg4 |
|
1627 |
"like Objects warn, but translates the string via the |
|
1628 |
resourcePack, thus giving a translated string automatically" |
|
1629 |
||
1630 |
super warn:(resources string:aString with:arg1 with:arg2 with:arg3 with:arg4) withCRs |
|
1631 |
||
1632 |
"Created: / 23.2.2000 / 09:43:04 / cg" |
|
1633 |
! |
|
1634 |
||
1635 |
withCursor:aCursor do:aBlock |
|
1636 |
"evaluate aBlock, showing aCursor in my topView and all of its subviews. |
|
1637 |
Return the value of aBlock." |
|
1638 |
||
1639 |
|w ret| |
|
1640 |
||
1641 |
w := self window. |
|
1642 |
w notNil ifTrue:[ |
|
1643 |
^ w withCursor:aCursor do:aBlock |
|
1644 |
]. |
|
1645 |
aCursor showWhile:[ret := aBlock value]. |
|
1646 |
^ ret. |
|
1647 |
||
1648 |
"Modified: / 23.9.1998 / 17:00:25 / cg" |
|
969
ac96df5a2f97
oops - had to undo some error-handling stuff.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1649 |
! |
ac96df5a2f97
oops - had to undo some error-handling stuff.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1650 |
|
1419 | 1651 |
withExecuteCursorDo:aBlock |
1652 |
"evaluate aBlock, showing an executeCursor in my topView and all of its subviews. |
|
1653 |
Return the value of aBlock." |
|
1654 |
||
1655 |
^ self withCursor:(Cursor execute) do:aBlock |
|
1656 |
||
1657 |
"Created: 14.12.1995 / 20:57:03 / cg" |
|
1658 |
! |
|
1659 |
||
1660 |
withReadCursorDo:aBlock |
|
1661 |
"evaluate aBlock, showing a readCursor in my topView and all of its subviews. |
|
1662 |
Return the value of aBlock." |
|
1663 |
||
1664 |
^ self withCursor:(Cursor read) do:aBlock |
|
1665 |
||
1666 |
"Created: 14.12.1995 / 20:56:47 / cg" |
|
1667 |
"Modified: 14.12.1995 / 20:57:36 / cg" |
|
1668 |
! |
|
1669 |
||
1670 |
withWaitCursorDo:aBlock |
|
1671 |
"evaluate aBlock, showing a waitCursor in my topView and all of its subviews. |
|
1672 |
Return the value of aBlock." |
|
1673 |
||
1674 |
^ self withCursor:Cursor wait do:aBlock |
|
1675 |
! ! |
|
1676 |
||
1677 |
!ApplicationModel methodsFor:'opening'! |
|
1678 |
||
1679 |
allButOpen |
|
1680 |
"create my views from the windowSpec, but do not open the main window." |
|
1681 |
||
1682 |
^ self allButOpenInterface:#windowSpec. |
|
1683 |
||
1684 |
"Modified: / 19.6.1998 / 01:48:26 / cg" |
|
1685 |
! |
|
1686 |
||
1687 |
allButOpenFrom:aSpec |
|
1688 |
"create my views but do not open the main window. |
|
1689 |
The argument is a spec which defines the interface." |
|
1690 |
||
1691 |
|realBuilder window| |
|
1692 |
||
1693 |
"/ DISABLED; see comment in basicInitialize |
|
1694 |
"/ |
|
1695 |
"/ " |
|
1696 |
"/ here, we kludge a bit: up to now, the builder was an |
|
1697 |
"/ instance of the no-op WindowBuilder. Now, it becomes |
|
1698 |
"/ a UIBuilder .... |
|
1699 |
"/ This allows for ApplicationModels without a UIBuilder |
|
1700 |
"/ if not needed. |
|
1701 |
"/ " |
|
1702 |
"/ realBuilder := UIBuilder new. |
|
1703 |
"/ builder := realBuilder. |
|
1704 |
"/ builder application:self. |
|
1705 |
"/ builder bindings:builder bindings. |
|
1706 |
||
1707 |
builder isNil ifTrue:[ |
|
1708 |
self createBuilder. |
|
1709 |
]. |
|
1710 |
||
1711 |
self preBuildWith:builder. |
|
1712 |
builder buildFromSpec:aSpec. |
|
1713 |
window := builder window. |
|
1714 |
window model:self. |
|
1715 |
(window respondsTo:#application:) ifTrue:[ |
|
1716 |
window application:self. |
|
1717 |
]. |
|
1718 |
self showingHelp ifTrue: [ActiveHelp startFor: self]. |
|
1719 |
self postBuildWith:builder. |
|
1720 |
||
1721 |
"Modified: / 19.6.1998 / 03:35:31 / cg" |
|
1722 |
! |
|
1723 |
||
1724 |
allButOpenInterface:aSymbol |
|
1725 |
"create my views but do not open the main window. |
|
1726 |
The argument specifies a selector of a method, |
|
1727 |
which when sent to myself should return a spec. |
|
1728 |
Notice, this returns the windowBuilder." |
|
1729 |
||
1730 |
self allButOpenFrom:(self interfaceSpecFor:aSymbol). |
|
1731 |
^ builder |
|
1732 |
||
1733 |
"Modified: / 19.6.1998 / 01:48:26 / cg" |
|
1734 |
! |
|
1735 |
||
1736 |
buildSubCanvas:spec withBuilder:aBuilder |
|
1737 |
"build a subcanvases spec into aSubcanvas" |
|
1738 |
||
1739 |
|sameApp prevSpec prevSource specToBuild| |
|
1740 |
||
1741 |
builder isNil ifTrue:[ |
|
1742 |
builder := aBuilder. |
|
1743 |
aBuilder isNil ifTrue:[ |
|
1744 |
self createBuilder |
|
1745 |
] |
|
1746 |
] ifFalse:[ |
|
1747 |
prevSpec := aBuilder spec. |
|
1748 |
prevSource := aBuilder source. |
|
1749 |
]. |
|
1750 |
||
1751 |
aBuilder source:self. |
|
1752 |
||
1753 |
"/ if the subcanvases appModel is NOT the same as |
|
1754 |
"/ the topApp, it must be pre/post-built. |
|
1755 |
"/ Otherwise, we invoke pre/post-builtAsSubcanvas. |
|
1756 |
"/ which provides a hook for redefinition in concrete appModels. |
|
1757 |
"/ This avoids invoking pre/postBuild twice for subCanvases which |
|
1758 |
"/ have the topApp as appModel. |
|
1759 |
||
1760 |
sameApp := aBuilder application == aBuilder window topView application. |
|
1761 |
sameApp ifTrue:[ |
|
1762 |
self preBuildAsSubcanvasWith:aBuilder. |
|
1763 |
] ifFalse:[ |
|
1764 |
self preBuildWith:aBuilder. |
|
1765 |
]. |
|
1766 |
||
1767 |
"/ subapps should not build the menu and other fullSpec stuff. |
|
1768 |
spec class == FullSpec ifTrue:[ |
|
1769 |
specToBuild := spec component. |
|
1770 |
] ifFalse:[ |
|
1771 |
specToBuild := spec. |
|
1772 |
]. |
|
1773 |
aBuilder buildFromSpec:specToBuild. |
|
1774 |
||
1775 |
sameApp ifTrue:[ |
|
1776 |
self postBuildAsSubcanvasWith:aBuilder. |
|
1777 |
] ifFalse:[ |
|
1778 |
self postBuildWith:aBuilder. |
|
1779 |
]. |
|
1780 |
||
1781 |
prevSpec notNil ifTrue:[ |
|
1782 |
"/ restore state in builder if original builder was used |
|
1783 |
aBuilder spec:prevSpec. |
|
1784 |
aBuilder source:prevSource. |
|
1785 |
]. |
|
1786 |
||
1787 |
^ aBuilder |
|
1788 |
||
1789 |
"Created: / 18.6.1998 / 20:08:45 / cg" |
|
1790 |
"Modified: / 8.7.1998 / 18:30:46 / cg" |
|
1359
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1791 |
! |
f40bfb94f862
allow for application to decide what type of
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1792 |
|
1419 | 1793 |
open |
1794 |
"open a standard interface" |
|
1795 |
||
1796 |
^ self openInterface |
|
1797 |
||
1798 |
"Modified: 3.5.1996 / 13:39:15 / cg" |
|
1799 |
! |
|
1800 |
||
1592
dd8fc50564c0
added #openAndWaitUntilVisible
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
1801 |
openAndWaitUntilVisible |
dd8fc50564c0
added #openAndWaitUntilVisible
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
1802 |
"open a standard interface, and wait until my window is visible" |
dd8fc50564c0
added #openAndWaitUntilVisible
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
1803 |
|
dd8fc50564c0
added #openAndWaitUntilVisible
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
1804 |
self open. |
dd8fc50564c0
added #openAndWaitUntilVisible
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
1805 |
self window waitUntilVisible. |
dd8fc50564c0
added #openAndWaitUntilVisible
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
1806 |
! |
dd8fc50564c0
added #openAndWaitUntilVisible
Claus Gittinger <cg@exept.de>
parents:
1590
diff
changeset
|
1807 |
|
1634 | 1808 |
openAs:windowType |
1809 |
"open a standard interface as slave, partner, dialog etc." |
|
1810 |
||
1811 |
^ self openInterfaceAs:windowType |
|
1812 |
||
1813 |
"Modified: 3.5.1996 / 13:39:15 / cg" |
|
1814 |
! |
|
1815 |
||
1816 |
openAsSlave |
|
1817 |
"open a standard interface as slave" |
|
1818 |
||
1819 |
^ self openAs:#slave |
|
1820 |
! |
|
1821 |
||
1419 | 1822 |
openAt:aPoint |
1823 |
"open a standard interface at some point" |
|
1824 |
||
1825 |
^ self openInterfaceAt:aPoint |
|
1826 |
||
1827 |
"Modified: 3.5.1996 / 13:39:15 / cg" |
|
1828 |
"Created: 14.2.1997 / 20:17:41 / cg" |
|
1829 |
! |
|
1830 |
||
1831 |
openDialog |
|
1832 |
"open the window - assumes that the builder has already setup |
|
1833 |
the interface." |
|
1834 |
||
1835 |
^ builder openDialog. |
|
1836 |
||
1837 |
"Modified: 14.2.1997 / 20:32:52 / cg" |
|
1838 |
! |
|
1839 |
||
1840 |
openDialogInterface:aSelector |
|
1841 |
"open a dialog" |
|
1842 |
||
1843 |
^ self openDialogInterface:aSelector withBindings:nil |
|
1844 |
||
1845 |
"Modified: 28.2.1997 / 14:08:01 / cg" |
|
1846 |
! |
|
1847 |
||
1848 |
openDialogInterface:aSelector withBindings:bindings |
|
1849 |
"open a dialog, given a spec-selector" |
|
1850 |
||
1851 |
^ SimpleDialog new |
|
1852 |
openFor:self |
|
1853 |
interface:aSelector |
|
1854 |
withBindings:bindings |
|
1855 |
||
1856 |
"Created: / 28.2.1997 / 14:07:45 / cg" |
|
1857 |
"Modified: / 23.1.1998 / 18:18:14 / cg" |
|
1858 |
! |
|
1859 |
||
1860 |
openDialogInterfaceSpec:aSpec withBindings:bindings |
|
1861 |
"open a dialog, given a spec" |
|
1862 |
||
1863 |
^ SimpleDialog new |
|
1864 |
openFor:self |
|
1865 |
interfaceSpec:aSpec |
|
1866 |
withBindings:bindings |
|
1867 |
||
1868 |
"Created: / 28.2.1997 / 14:07:45 / cg" |
|
1869 |
"Modified: / 23.1.1998 / 18:18:14 / cg" |
|
1870 |
! |
|
1871 |
||
1872 |
openDialogSpec:aSpec withBindings:bindings |
|
1873 |
"open a dialog" |
|
1874 |
||
1875 |
^ SimpleDialog new |
|
1876 |
openFor:self |
|
1877 |
spec:aSpec |
|
1878 |
withBindings:bindings |
|
1879 |
||
1880 |
"Modified: / 23.1.1998 / 18:18:14 / cg" |
|
1881 |
"Created: / 20.5.1998 / 20:27:56 / cg" |
|
1882 |
! |
|
1883 |
||
1884 |
openInterface |
|
1885 |
"open a standard interface. |
|
1886 |
||
1887 |
Subclasses which do not have an interfaceSpec |
|
1888 |
should redefine this method and create & open their view(s) there. |
|
1889 |
(see Launcher as an example)." |
|
1890 |
||
1891 |
^ self openInterface:#windowSpec |
|
1892 |
||
1893 |
"Modified: / 9.9.1996 / 22:39:23 / stefan" |
|
1894 |
"Modified: / 23.1.1998 / 18:16:50 / cg" |
|
1895 |
! |
|
1896 |
||
1897 |
openInterface:aSymbol |
|
1898 |
"open a specific interface. |
|
1899 |
The argument, aSymbol specifies which interface. The concrete |
|
1900 |
application subclass must provide a method with that name, |
|
1901 |
which must return an interfaceSpec. This is forwarded to |
|
1902 |
the builder to create the views. |
|
1903 |
Typically, applications only use one interface, |
|
1904 |
returned by the #windowSpec method." |
|
1905 |
||
1906 |
self allButOpenInterface:aSymbol. |
|
1907 |
self openWindow. |
|
1908 |
^ builder |
|
1909 |
||
1910 |
"Modified: 14.2.1997 / 20:25:33 / cg" |
|
1911 |
! |
|
1912 |
||
1634 | 1913 |
openInterface:aSymbol as:windowType |
1914 |
"open a specific interface. |
|
1915 |
The argument, aSymbol specifies which interface. |
|
1916 |
The concrete application subclass must provide a method with that name, |
|
1917 |
which must return an interfaceSpec. This is forwarded to the builder to create the views. |
|
1918 |
Typically, applications only use one interface, returned by the #windowSpec method. |
|
1919 |
The windowType can be any of #slave, #partner, #dialog, #popUp etc." |
|
1920 |
||
1921 |
self allButOpenInterface:aSymbol. |
|
1922 |
self openWindowAs:windowType. |
|
1923 |
^ builder |
|
1924 |
||
1925 |
"Modified: 14.2.1997 / 20:25:33 / cg" |
|
1926 |
! |
|
1927 |
||
1419 | 1928 |
openInterface:aSymbol at:aLocation |
1929 |
"open a specific interface. |
|
1930 |
||
1931 |
The argument, aSymbol specifies which interface. The concrete |
|
1932 |
application subclass must provide a method with that name, |
|
1933 |
which must return an interfaceSpec. This is forwarded to |
|
1934 |
the builder to create the views. |
|
1935 |
Typically, applications only use one interface, |
|
1936 |
returned by the #windowSpec method." |
|
1937 |
||
1938 |
self allButOpenInterface:aSymbol. |
|
1939 |
self openWindowAt:aLocation. |
|
1940 |
^ builder |
|
1941 |
||
1942 |
"Created: 14.2.1997 / 20:19:44 / cg" |
|
1943 |
! |
|
1944 |
||
1634 | 1945 |
openInterfaceAs:windowType |
1946 |
"open a standard interface. |
|
1947 |
The windowType can be any of #slave, #partner, #dialog, #popUp etc. |
|
1948 |
Subclasses which do not have an interfaceSpec |
|
1949 |
should redefine this method and create & open their view(s) there. |
|
1950 |
(see Launcher as an example)." |
|
1951 |
||
1952 |
^ self openInterface:#windowSpec as:windowType |
|
1953 |
||
1954 |
"Modified: / 9.9.1996 / 22:39:23 / stefan" |
|
1955 |
"Modified: / 23.1.1998 / 18:16:50 / cg" |
|
1956 |
! |
|
1957 |
||
1419 | 1958 |
openInterfaceAt:aLocation |
1959 |
"open a standard interface." |
|
1960 |
||
1961 |
^ self openInterface:#windowSpec at:aLocation |
|
1962 |
||
1963 |
"Created: / 14.2.1997 / 20:18:20 / cg" |
|
1964 |
"Modified: / 23.1.1998 / 18:17:13 / cg" |
|
1965 |
! |
|
1966 |
||
1967 |
openInterfaceModal |
|
1968 |
"open a standard interface as a modal dialog. |
|
1969 |
||
1970 |
Subclasses which do not have an interfaceSpec |
|
1971 |
should redefine this method and create & open their view(s) there. |
|
1972 |
(see Launcher as an example)." |
|
1973 |
||
1974 |
^ self openInterfaceModal:#windowSpec |
|
1975 |
||
1976 |
"Modified: / 9.9.1996 / 22:39:23 / stefan" |
|
1977 |
"Modified: / 23.1.1998 / 18:17:17 / cg" |
|
1978 |
! |
|
1979 |
||
1980 |
openInterfaceModal:aSymbol |
|
1981 |
"open a specific interface as a modal dialog. |
|
1982 |
The argument, aSymbol specifies which interface. The concrete |
|
1983 |
application subclass must provide a method with that name, |
|
1984 |
which must return an interfaceSpec. This is forwarded to |
|
1985 |
the builder to create the views. |
|
1986 |
Typically, applications only use one interface, |
|
1987 |
returned by the #windowSpec method." |
|
1988 |
||
1989 |
self allButOpenInterface:aSymbol. |
|
1990 |
self openWindowModal. |
|
1991 |
^ builder |
|
1992 |
||
1993 |
"Modified: 14.2.1997 / 20:25:33 / cg" |
|
969
ac96df5a2f97
oops - had to undo some error-handling stuff.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1994 |
! |
ac96df5a2f97
oops - had to undo some error-handling stuff.
Claus Gittinger <cg@exept.de>
parents:
967
diff
changeset
|
1995 |
|
1419 | 1996 |
openInterfaceModal:aSymbol at:location |
1997 |
"open a specific interface modal at some screen location. |
|
1998 |
The argument, aSymbol specifies which interface. The concrete |
|
1999 |
application subclass must provide a method with that name, |
|
2000 |
which must return an interfaceSpec. This is forwarded to |
|
2001 |
the builder to create the views. |
|
2002 |
Typically, applications only use one interface, |
|
2003 |
returned by the #windowSpec method." |
|
2004 |
||
2005 |
self allButOpenInterface:aSymbol. |
|
2006 |
self openWindowModalAt:location. |
|
2007 |
^ builder |
|
2008 |
||
2009 |
"Modified: 14.2.1997 / 20:25:33 / cg" |
|
2010 |
! |
|
2011 |
||
2012 |
openModal |
|
2013 |
"open a standard interface as a modal dialog" |
|
2014 |
||
2015 |
^ self openInterfaceModal |
|
2016 |
||
2017 |
"Modified: 3.5.1996 / 13:39:15 / cg" |
|
2018 |
! |
|
2019 |
||
2020 |
openOnDevice:aDevice |
|
2021 |
"open a standard interface on some other device" |
|
2022 |
||
2023 |
self setDevice:aDevice. |
|
1444 | 2024 |
Screen currentScreenQuerySignal answer:aDevice |
2025 |
do:[ |
|
2026 |
^ self open |
|
2027 |
] |
|
1419 | 2028 |
|
2029 |
"Created: 13.1.1997 / 21:24:11 / cg" |
|
2030 |
"Modified: 13.1.1997 / 21:24:30 / cg" |
|
2031 |
! |
|
2032 |
||
2033 |
openSpec:anInterfaceSpec |
|
2034 |
"open a view as specified in anInterfaceSpec." |
|
2035 |
||
2036 |
self allButOpenFrom:anInterfaceSpec. |
|
2037 |
self openWindow. |
|
2038 |
^ builder |
|
2039 |
||
2040 |
"Modified: / 14.2.1997 / 20:25:33 / cg" |
|
2041 |
"Created: / 20.5.1998 / 20:08:51 / cg" |
|
2042 |
! |
|
2043 |
||
2044 |
openSpecModal:anInterfaceSpec |
|
2045 |
"open an interface spec modal" |
|
2046 |
||
2047 |
self allButOpenFrom:anInterfaceSpec. |
|
2048 |
self openWindowModal. |
|
2049 |
^ builder |
|
2050 |
||
2051 |
"Modified: / 14.2.1997 / 20:25:33 / cg" |
|
2052 |
"Created: / 20.5.1998 / 20:20:21 / cg" |
|
2053 |
! |
|
2054 |
||
2055 |
openWindow |
|
2056 |
"open the window - assumes that the builder has already setup |
|
2057 |
the interface." |
|
2058 |
||
2059 |
builder openWindow. |
|
2060 |
||
2061 |
"Created: 14.2.1997 / 20:20:39 / cg" |
|
2062 |
! |
|
2063 |
||
1634 | 2064 |
openWindowAs:windowType |
2065 |
"open the window - assumes that the builder has already setup the interface. |
|
2066 |
The windowType can be any of #slave, #partner, #dialog, #popUp etc." |
|
2067 |
||
2068 |
builder openAt:nil withExtent:nil andType:windowType |
|
2069 |
! |
|
2070 |
||
1419 | 2071 |
openWindowAt:aLocation |
2072 |
"open the window - assumes that the builder has already setup |
|
2073 |
the interface." |
|
2074 |
||
2075 |
builder openWindowAt:aLocation. |
|
2076 |
||
2077 |
"Created: 14.2.1997 / 20:20:55 / cg" |
|
2078 |
! |
|
2079 |
||
2080 |
openWindowAtCenter |
|
2081 |
"open the window centered on the screen |
|
2082 |
- assumes that the builder has already setup the interface." |
|
2083 |
||
2084 |
builder openWindowAt:#center |
|
2085 |
||
2086 |
"Created: 14.2.1997 / 20:20:55 / cg" |
|
2087 |
! |
|
2088 |
||
2089 |
openWindowModal |
|
2090 |
"open the window - assumes that the builder has already setup |
|
2091 |
the interface." |
|
2092 |
||
2093 |
"/ builder openDialog. |
|
2094 |
builder |
|
2095 |
openAt:nil |
|
2096 |
withExtent:nil |
|
2097 |
andType:#dialog |
|
2098 |
||
2099 |
"Created: 14.2.1997 / 20:20:39 / cg" |
|
2100 |
! |
|
2101 |
||
2102 |
openWindowModalAt:aLocation |
|
2103 |
"open the window modal - assumes that the builder has already setup |
|
2104 |
the interface." |
|
2105 |
||
2106 |
builder openDialogAt:aLocation. |
|
2107 |
||
2108 |
"Created: 14.2.1997 / 20:20:55 / cg" |
|
2109 |
! |
|
2110 |
||
1478 | 2111 |
openWithExtent:extPoint |
2112 |
"open a standard interface with given extent" |
|
2113 |
||
2114 |
|bldr| |
|
2115 |
||
2116 |
bldr := self allButOpen. |
|
2117 |
bldr openWithExtent:extPoint. |
|
2118 |
^ bldr |
|
2119 |
||
2120 |
"Modified: 3.5.1996 / 13:39:15 / cg" |
|
2121 |
! |
|
2122 |
||
1419 | 2123 |
postApplicationProcessCreate:newProcess windowGroup:newGroup |
2124 |
"this is sent whenever a new application is launched from this app, |
|
2125 |
which forks its own windowGroup process. Allows for process group management, |
|
2126 |
or process-global exception handlers to be installed. |
|
2127 |
Nothing done here - to be redefined in concrete applications" |
|
2128 |
||
2129 |
! |
|
2130 |
||
2131 |
postBuildAsSubcanvasWith:aBuilder |
|
2132 |
"this is sent after an interface is built from a spec as subcanvas. |
|
2133 |
Can be redefined in subclasses for additional setup after |
|
2134 |
the subcanvas view has been built, but not yet opened." |
|
2135 |
||
2136 |
|sameApp| |
|
2137 |
||
2138 |
sameApp := aBuilder application == aBuilder window topView application. |
|
2139 |
||
2140 |
"/ If I am opened as subcanvas in another application |
|
2141 |
"/ then treat this like a regular open. |
|
2142 |
"/ otherwise ignore it. |
|
2143 |
sameApp ifFalse:[ |
|
2144 |
self postBuildWith:aBuilder. |
|
2145 |
] |
|
2146 |
||
2147 |
"Modified: / 8.7.1998 / 18:28:55 / cg" |
|
2148 |
! |
|
2149 |
||
2150 |
postBuildWith:aBuilder |
|
2151 |
"this is sent after an interface is built from a spec. |
|
2152 |
Can be redefined in subclasses for additional setup after |
|
2153 |
the view has been built, but not yet opened." |
|
2154 |
! |
|
2155 |
||
1432
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2156 |
postOpenAsSubcanvasWith:aBuilder |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2157 |
"this is sent after the applications window is opened inside another application. |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2158 |
Can be redefined in subclasses for actions after opening the view." |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2159 |
! |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2160 |
|
1419 | 2161 |
postOpenWith:aBuilder |
2162 |
"this is sent after the applications main window is opened. |
|
2163 |
Can be redefined in subclasses for actions after opening the view." |
|
2164 |
||
2165 |
||
138 | 2166 |
! |
2167 |
||
1419 | 2168 |
preBuildAsSubcanvasWith:aBuilder |
2169 |
"this is sent before an interface is built from a spec as a subcanvas. |
|
2170 |
Can be redefined for apps which need to be informed about that." |
|
2171 |
||
2172 |
"Modified: / 8.7.1998 / 18:29:34 / cg" |
|
2173 |
! |
|
2174 |
||
2175 |
preBuildWith:aBuilder |
|
2176 |
"this is sent before an interface is built from a spec. |
|
2177 |
Can be redefined in subclasses. |
|
2178 |
mhmh - what should this do here ?" |
|
2179 |
! ! |
|
2180 |
||
2181 |
!ApplicationModel methodsFor:'private'! |
|
2182 |
||
2183 |
builderClass |
|
2184 |
"return the UIBuilder class for me. |
|
2185 |
This method can be redefined if (eventually) there are |
|
2186 |
spec readers for other UI languages (motif UIL ?)" |
|
2187 |
||
2188 |
^ UIBuilder |
|
2189 |
||
2190 |
"Created: / 19.6.1998 / 01:39:26 / cg" |
|
2191 |
"Modified: / 19.6.1998 / 01:45:24 / cg" |
|
2192 |
! |
|
2193 |
||
2194 |
createBuilder |
|
1431 | 2195 |
"create a WindowBuilder if not already present" |
2196 |
||
1419 | 2197 |
builder isNil ifTrue:[ |
2198 |
builder := self builderClass new. |
|
2199 |
builder application:self. |
|
2200 |
] |
|
2201 |
||
2202 |
"Created: / 19.6.1998 / 03:32:37 / cg" |
|
2203 |
! |
|
2204 |
||
2205 |
opened:whichTopView |
|
2206 |
"the topView has been opened. |
|
2207 |
This is sent by my topView when its really open |
|
2208 |
(i.e. finally visible)" |
|
2209 |
||
2210 |
self addTopViewsToCurrentProject. |
|
2211 |
self postOpenWith:builder |
|
2212 |
! |
|
2213 |
||
2214 |
selfResponsibleFor:aKey |
|
1431 | 2215 |
"internal: return true, if I am to provide a value for some aspect." |
2216 |
||
1419 | 2217 |
^ (aKey isNil or:[masterApplication isNil or:[self respondsTo:aKey]]) |
2218 |
! ! |
|
2219 |
||
2220 |
!ApplicationModel methodsFor:'queries'! |
|
2221 |
||
2222 |
defaultWindowType |
|
2223 |
"Applications come up non-modal, by default" |
|
2224 |
||
2225 |
^ #normal |
|
2226 |
||
2227 |
"Created: 17.1.1997 / 19:57:34 / cg" |
|
2228 |
! |
|
2229 |
||
2230 |
graphicsDevice |
|
2231 |
"return the device I want to open my views on. |
|
2232 |
The default (if not created with #onDevice:) is the currently |
|
2233 |
active screen." |
|
2234 |
||
2235 |
^ device |
|
2236 |
||
2237 |
"Created: 5.7.1996 / 17:51:31 / cg" |
|
1132
b801d744051b
kludge & hook to allow modeless appModels to
Claus Gittinger <cg@exept.de>
parents:
1118
diff
changeset
|
2238 |
! |
b801d744051b
kludge & hook to allow modeless appModels to
Claus Gittinger <cg@exept.de>
parents:
1118
diff
changeset
|
2239 |
|
1419 | 2240 |
interfaceSpecFor:aSelector |
2241 |
"return an interface spec. |
|
2242 |
Here, the query is forwarded to my class. |
|
2243 |
Can be refefined in subclasses which want to provide per-instance specs." |
|
2244 |
||
2245 |
^ self class interfaceSpecFor:aSelector |
|
2246 |
||
2247 |
"Created: / 25.1.1998 / 19:45:12 / cg" |
|
2248 |
"Modified: / 25.1.1998 / 19:47:09 / cg" |
|
2249 |
! |
|
2250 |
||
1481
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2251 |
isOpen |
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2252 |
"answer true if the application's window is open" |
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2253 |
|
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2254 |
|win| |
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2255 |
|
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2256 |
^ (win := self window) notNil and:[win isOpen] |
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2257 |
! |
e1922b505268
Define #isOpen to check wether an application has an open window.
Stefan Vogel <sv@exept.de>
parents:
1479
diff
changeset
|
2258 |
|
1419 | 2259 |
processName |
2260 |
"return a name to be shown for me in the process monitor" |
|
2261 |
||
2262 |
self class == ApplicationModel ifTrue:[ |
|
2263 |
^ 'Application' |
|
2264 |
]. |
|
2265 |
^ self class nameWithoutPrefix |
|
2266 |
||
2267 |
"Modified: / 4.12.1997 / 12:39:14 / cg" |
|
2268 |
! |
|
2269 |
||
2270 |
resolveClassNamed:something inClass:aClass |
|
2271 |
"return the class from something, a class, symbol, string or nil. |
|
1548 | 2272 |
first we are looking in the namespace of the application, then in the |
2273 |
current namespace and finally in Smalltalk |
|
1419 | 2274 |
" |
2275 |
||
2276 |
^ Smalltalk resolveName:something inClass:aClass. |
|
2277 |
! |
|
2278 |
||
2279 |
resolveName:something |
|
2280 |
"return the class from something, a class, symbol, string or nil. |
|
1548 | 2281 |
first we are looking in the namespace of the application, then in the |
2282 |
current namespace and finally in Smalltalk |
|
1419 | 2283 |
" |
2284 |
^ self resolveName:something inClass:self class |
|
2285 |
! |
|
2286 |
||
2287 |
resolveName:something inClass:aClass |
|
2288 |
"return the class from something, a class, symbol, string or nil. |
|
1548 | 2289 |
first we are looking in the namespace of the application, |
2290 |
then in the current namespace and finally in Smalltalk |
|
1419 | 2291 |
" |
2292 |
|cls| |
|
2293 |
||
2294 |
aClass notNil ifTrue:[ |
|
2295 |
(cls := Smalltalk resolveName:something inClass:aClass) notNil ifTrue:[ |
|
2296 |
^ cls |
|
2297 |
]. |
|
2298 |
||
2299 |
masterApplication notNil ifTrue:[ |
|
2300 |
^ masterApplication resolveName:something |
|
2301 |
] |
|
2302 |
]. |
|
2303 |
^ nil |
|
2304 |
! |
|
2305 |
||
2306 |
topApplication |
|
2307 |
"return the top-master application" |
|
2308 |
||
2309 |
masterApplication isNil ifTrue:[ |
|
2310 |
^ self |
|
2311 |
]. |
|
2312 |
^ masterApplication topApplication |
|
2313 |
||
2314 |
"Created: / 6.6.1998 / 19:40:42 / cg" |
|
2315 |
! ! |
|
2316 |
||
2317 |
!ApplicationModel methodsFor:'startup / release'! |
|
2318 |
||
2319 |
applicationWindowClass |
|
1431 | 2320 |
"return the class used for my (top-) windows" |
2321 |
||
1419 | 2322 |
^ ApplicationWindow |
2323 |
! |
|
2324 |
||
2325 |
close |
|
2326 |
"this is sent by my topView when about to be closed |
|
2327 |
by the program (not by the windowManager). |
|
2328 |
Notice, that we get a closeRequest message if closed by the windowManager, |
|
2329 |
which can be rejected by the app (or confirmed via a dialog) |
|
2330 |
Could be redefined in subclasses." |
|
2331 |
||
2332 |
self closeDownViews |
|
1132
b801d744051b
kludge & hook to allow modeless appModels to
Claus Gittinger <cg@exept.de>
parents:
1118
diff
changeset
|
2333 |
! |
b801d744051b
kludge & hook to allow modeless appModels to
Claus Gittinger <cg@exept.de>
parents:
1118
diff
changeset
|
2334 |
|
1419 | 2335 |
closeDownViews |
2336 |
"close down the applications view(s)" |
|
2337 |
||
2338 |
|wg wgProcess views| |
|
2339 |
||
2340 |
self release. |
|
2341 |
ActiveHelp stopFor:self. |
|
2342 |
||
2343 |
(wg := self windowGroup) notNil ifTrue:[ |
|
2344 |
wgProcess := wg process. |
|
2345 |
(Processor activeProcess ~~ wgProcess |
|
2346 |
and:[wgProcess notNil]) ifTrue:[ |
|
2347 |
wgProcess terminate |
|
2348 |
] ifFalse:[ |
|
2349 |
wg closeDownViews. |
|
2350 |
] |
|
2351 |
] |
|
2352 |
! |
|
2353 |
||
2354 |
closeRequest |
|
2355 |
"this is sent by my topView when about to be closed by the windowManager. |
|
2356 |
Could be redefined in subclasses to suppress close or confirm." |
|
2357 |
||
1528 | 2358 |
|sav window| |
2359 |
||
2360 |
window := self window. |
|
2361 |
window isNil ifTrue:[ |
|
1461
f3ad0001d240
fixed: raise leaveSignal in closeRequest for a modal opened view
tm
parents:
1454
diff
changeset
|
2362 |
'ApplicationModel [warning]: oops - closeRequest for non-view application arrived' infoPrintCR. |
f3ad0001d240
fixed: raise leaveSignal in closeRequest for a modal opened view
tm
parents:
1454
diff
changeset
|
2363 |
^ self |
f3ad0001d240
fixed: raise leaveSignal in closeRequest for a modal opened view
tm
parents:
1454
diff
changeset
|
2364 |
]. |
f3ad0001d240
fixed: raise leaveSignal in closeRequest for a modal opened view
tm
parents:
1454
diff
changeset
|
2365 |
|
1528 | 2366 |
(window isTopView not) ifTrue:[ |
2367 |
window topView isModal ifTrue:[ |
|
1461
f3ad0001d240
fixed: raise leaveSignal in closeRequest for a modal opened view
tm
parents:
1454
diff
changeset
|
2368 |
WindowGroup leaveSignal raise. |
f3ad0001d240
fixed: raise leaveSignal in closeRequest for a modal opened view
tm
parents:
1454
diff
changeset
|
2369 |
]. |
f3ad0001d240
fixed: raise leaveSignal in closeRequest for a modal opened view
tm
parents:
1454
diff
changeset
|
2370 |
|
1419 | 2371 |
'ApplicationModel [warning]: oops - closeRequest for non-TopView arrived' infoPrintCR. |
2372 |
^ self |
|
2373 |
]. |
|
2374 |
||
2375 |
"/ In multiView apps, tell my master. |
|
2376 |
"/ (but not if I am a modal reincarnation) |
|
2377 |
(masterApplication notNil |
|
1528 | 2378 |
and:[window isModal not]) ifTrue:[ |
1419 | 2379 |
|
2380 |
"/ temporary clear my masterApplication to prevent |
|
2381 |
"/ endless recursion, in case the master sends me |
|
2382 |
"/ a closeRequest (although, it is supposed to |
|
2383 |
"/ send me a closeDownViews ...) |
|
2384 |
||
2385 |
sav := masterApplication. |
|
2386 |
masterApplication := nil. |
|
1528 | 2387 |
sav closeRequestFor:window. |
1419 | 2388 |
|
2389 |
"/ restore - in case master did not want me to close ... |
|
2390 |
masterApplication := sav. |
|
2391 |
] ifFalse:[ |
|
2392 |
"/ ST/X does close-check by redefining this message without |
|
2393 |
"/ a supersend; |
|
2394 |
"/ VW does it by returning false from requestForWindowClose |
|
2395 |
"/ sigh. |
|
2396 |
||
2397 |
self requestForWindowClose ifTrue:[ |
|
1565
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2398 |
window isSlave ifTrue:[ |
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2399 |
window destroy |
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2400 |
] ifFalse:[ |
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2401 |
self closeDownViews |
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2402 |
] |
1419 | 2403 |
] |
2404 |
]. |
|
2405 |
||
2406 |
"Modified: / 19.6.1998 / 01:37:17 / cg" |
|
2407 |
! |
|
2408 |
||
2409 |
closeRequestFor:aTopView |
|
2410 |
"this is sent by any of my topViews when about to be closed by the |
|
2411 |
windowmanager. For backward compatibility with single-view applications, |
|
2412 |
this is forwarded here to a simple (non topView-specific) closeRequest, |
|
2413 |
effectively closing all of my views. |
|
2414 |
MultiView applications should redefine this method if closing of individual |
|
2415 |
views closing is to be caught and/or should not close all of them." |
|
2416 |
||
1633
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2417 |
|savedMaster myWindow| |
1565
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2418 |
|
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2419 |
myWindow := self window. |
1419 | 2420 |
|
2421 |
"/ In multiView apps, tell my master. |
|
2422 |
"/ (but not if I am a modal reincarnation) |
|
2423 |
(masterApplication notNil |
|
1565
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2424 |
and:[myWindow topView isModal not]) ifTrue:[ |
1419 | 2425 |
|
2426 |
"/ temporary clear my masterApplication to prevent |
|
2427 |
"/ endless recursion, in case the master sends me |
|
2428 |
"/ a closeRequest (although, it is supposed to |
|
2429 |
"/ send me a closeDownViews ...) |
|
2430 |
||
1633
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2431 |
savedMaster := masterApplication. |
1419 | 2432 |
masterApplication := nil. |
1565
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2433 |
aTopView isSlave ifTrue:[ |
1633
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2434 |
savedMaster closeRequestFor:aTopView. |
1565
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2435 |
] ifFalse:[ |
1633
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2436 |
savedMaster closeRequestFor:myWindow. |
1565
ea35a676f0b1
do not shutDown the whole app, if a slave is closing down.
Claus Gittinger <cg@exept.de>
parents:
1556
diff
changeset
|
2437 |
]. |
1419 | 2438 |
|
2439 |
"/ restore - in case master did not want me to close ... |
|
1633
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2440 |
masterApplication := savedMaster. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2441 |
^ self |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2442 |
]. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2443 |
|
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2444 |
(aTopView == myWindow) ifTrue:[ |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2445 |
self closeRequest. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2446 |
^ self |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2447 |
]. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2448 |
|
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2449 |
(aTopView isPartner or:[aTopView isMaster]) ifTrue:[ |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2450 |
aTopView application closeRequest. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2451 |
self closeRequest. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2452 |
^ self. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2453 |
]. |
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2454 |
|
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2455 |
aTopView application closeRequest. |
1419 | 2456 |
! |
2457 |
||
2458 |
doAccept |
|
2459 |
"this is invoked by the Return-Key (if returnIsOK) or |
|
2460 |
the ok-button (if any), IFF the application has been |
|
2461 |
opened modal (i.e. as a dialog)." |
|
2462 |
||
2463 |
"/ the following is a bad kludge - |
|
2464 |
"/ actually, modal apps should inherit from SimpleDialog |
|
2465 |
"/ (then, things would be clean) |
|
2466 |
"/ However, it may be useful, to open some app (which is normally |
|
2467 |
"/ modeless) as a modal one as well. |
|
2468 |
"/ In that, case, we have no acceptHolder (see SimpleDialog), |
|
2469 |
"/ to remember the accept vs. cancel case. |
|
2470 |
"/ |
|
2471 |
self window isModal ifTrue:[ |
|
2472 |
"/ mhmh - is this a good idea ? |
|
2473 |
(self respondsTo:#accept) ifTrue:[ |
|
2474 |
self accept |
|
2475 |
] ifFalse:[ |
|
2476 |
self closeRequest. |
|
2477 |
]. |
|
2478 |
^ self |
|
2479 |
]. |
|
2480 |
||
2481 |
^ self "/ nothing done here ... |
|
2482 |
! |
|
2483 |
||
2484 |
doCancel |
|
2485 |
"this is invoked by the Escape-Key (if escapeIsCancel) or |
|
2486 |
the cancel-button (if any), IFF the application has been |
|
2487 |
opened modal (i.e. as a dialog)." |
|
2488 |
||
2489 |
"/ the following is a bad kludge - |
|
2490 |
"/ actually, modal apps should inherit from SimpleDialog |
|
2491 |
"/ (then, things would be clean) |
|
2492 |
"/ However, it may be useful, to open some app (which is normally |
|
2493 |
"/ modeless) as a modal one as well. |
|
2494 |
"/ In that, case, we have no acceptHolder (see SimpleDialog), |
|
2495 |
"/ to remember the accept vs. cancel case. |
|
1417 | 2496 |
"/ |
1419 | 2497 |
self window isModal ifTrue:[ |
2498 |
"/ mhmh - is this a good idea ? |
|
2499 |
(self respondsTo:#cancel) ifTrue:[ |
|
2500 |
self cancel |
|
2501 |
] ifFalse:[ |
|
2502 |
self closeRequest. |
|
2503 |
]. |
|
2504 |
^ self |
|
2505 |
]. |
|
2506 |
^ self "/ nothing done here ... |
|
2507 |
! |
|
2508 |
||
2509 |
releaseAsSubCanvas |
|
2510 |
"a subcanvas is closed or switching to a new application. |
|
2511 |
Can be redefined to perform a self release in this case." |
|
2512 |
||
2513 |
"/ used to self release here, |
|
2514 |
"/ but that is incompatible to VW (RefactoryBrowser). |
|
2515 |
"/ Therefore, if you need it, you MUST now redefine |
|
2516 |
"/ this method. |
|
2517 |
! |
|
2518 |
||
2519 |
restarted |
|
2520 |
"sent by my topWindow, when restarted from an image. |
|
2521 |
Nothing done here, but can be redefined to perform any actions |
|
2522 |
required to reset the application after an image-restart. |
|
2523 |
(for example: check if application files are still around, restart |
|
2524 |
subprocesses etc.)." |
|
2525 |
||
2526 |
"Modified: 1.6.1996 / 16:55:50 / cg" |
|
2527 |
! |
|
2528 |
||
2529 |
saveAndTerminateRequest |
|
2530 |
"some windowManagers send this to shut down an application |
|
2531 |
and have it save its state for restart. |
|
2532 |
Can be redefined in subclasses" |
|
2533 |
||
2534 |
self closeRequest |
|
2535 |
! |
|
2536 |
||
2537 |
saveAndTerminateRequestFor:aTopView |
|
2538 |
"some windowManagers send this to shut down an application |
|
2539 |
and have it save its state for restart. |
|
2540 |
Can be redefined in subclasses" |
|
2541 |
||
2542 |
self saveAndTerminateRequest |
|
2543 |
! |
|
2544 |
||
2545 |
windowClass |
|
2546 |
"return the type of topWindow I would like to have created. |
|
2547 |
Can be redefined in subclasses to allow for specialized |
|
2548 |
subclass of ApplicationWindow to be returned here." |
|
2549 |
||
2550 |
^ ApplicationWindow |
|
2551 |
! ! |
|
2552 |
||
2553 |
!ApplicationModel methodsFor:'window events'! |
|
2554 |
||
2555 |
dispatchEvent:event |
|
2556 |
"dispatch a user-pushed event. |
|
2557 |
This allows for events for an appModel to be pushed into the event queue |
|
2558 |
the same way as events for a view are pushable." |
|
2559 |
||
2560 |
^ self |
|
2561 |
dispatchEvent:event |
|
2562 |
withFocusOn:nil |
|
2563 |
delegate:true |
|
2564 |
||
2565 |
! |
|
2566 |
||
2567 |
dispatchEvent:evType arguments:evArgs withFocusOn:focusView delegate:doDelegate |
|
2568 |
"dispatch a user-pushed event. |
|
2569 |
This allows for events for an appModel to be pushed into the event queue |
|
2570 |
the same way as events for a view are pushable." |
|
2571 |
||
2572 |
self perform:evType withArguments:evArgs |
|
2573 |
||
2574 |
"Created: / 20.6.1998 / 16:36:54 / cg" |
|
2575 |
"Modified: / 20.6.1998 / 16:44:05 / cg" |
|
1290 | 2576 |
! |
2577 |
||
1419 | 2578 |
dispatchEvent:ev type:evType arguments:evArgs withFocusOn:focusView delegate:doDelegate |
2579 |
"dispatch a user-pushed event. |
|
2580 |
This allows for events for an appModel to be pushed into the event queue |
|
2581 |
the same way as events for a view are pushable." |
|
2582 |
||
2583 |
self perform:evType withArguments:evArgs |
|
2584 |
||
2585 |
"Created: / 20.6.1998 / 16:36:54 / cg" |
|
2586 |
"Modified: / 20.6.1998 / 16:44:05 / cg" |
|
2587 |
! |
|
2588 |
||
2589 |
dispatchEvent:event withFocusOn:focusViewOrNil |
|
2590 |
"dispatch a user-pushed event. |
|
2591 |
This allows for events for an appModel to be pushed into the event queue |
|
2592 |
the same way as events for a view are pushable." |
|
2593 |
||
2594 |
^ self |
|
2595 |
dispatchEvent:event |
|
2596 |
withFocusOn:focusViewOrNil |
|
2597 |
delegate:true |
|
2598 |
||
2599 |
||
2600 |
! |
|
2601 |
||
2602 |
dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate |
|
2603 |
"dispatch a user-pushed event. |
|
2604 |
This allows for events for an appModel to be pushed into the event queue |
|
2605 |
the same way as events for a view are pushable." |
|
2606 |
||
2607 |
^ self |
|
2608 |
dispatchEvent:event |
|
2609 |
type:event type |
|
2610 |
arguments:(event arguments) |
|
2611 |
withFocusOn:focusViewOrNil |
|
2612 |
delegate:doDelegate |
|
2613 |
||
2614 |
||
2615 |
! |
|
2616 |
||
2617 |
noticeOfWindowClose:aWindow |
|
1432
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2618 |
"sent when a topView or applicationSubView has been closed. |
1419 | 2619 |
Can be redefined in subclasses for cleanup." |
2620 |
||
1432
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2621 |
"/ ST-80 compatibility |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2622 |
self windowEvent:(#close -> aWindow) from:aWindow. |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2623 |
^ self |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2624 |
|
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2625 |
"Created: / 18.6.1998 / 18:56:31 / cg" |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2626 |
"Modified: / 18.6.1998 / 19:14:16 / cg" |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2627 |
! |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2628 |
|
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2629 |
noticeOfWindowOpen:aWindow |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2630 |
"sent when a topView or applicationSubView has been opened. |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2631 |
Can be redefined in subclasses." |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2632 |
|
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2633 |
"/ ST-80 compatibility |
6dc94e38fa8e
postOpenedWith, windowEvent and noticeOfWindow-Whatever
tm
parents:
1431
diff
changeset
|
2634 |
self windowEvent:(#open -> aWindow) from:aWindow. |
1419 | 2635 |
^ self |
2636 |
||
2637 |
"Created: / 18.6.1998 / 18:56:31 / cg" |
|
2638 |
"Modified: / 18.6.1998 / 19:14:16 / cg" |
|
2639 |
! |
|
2640 |
||
2641 |
requestForWindowClose |
|
2642 |
"the applicationWindow wants to know, if a close |
|
2643 |
is ok. Return false if not." |
|
2644 |
||
2645 |
|w k| |
|
2646 |
||
2647 |
builder notNil ifTrue:[ |
|
2648 |
(w := builder window) notNil ifTrue:[ |
|
2649 |
(k := w keyboardProcessor) notNil ifTrue:[ |
|
2650 |
^ k requestForWindowClose |
|
2651 |
] |
|
2652 |
] |
|
2653 |
]. |
|
2654 |
^ true |
|
2655 |
||
2656 |
"Modified: / 18.6.1998 / 19:14:16 / cg" |
|
2657 |
"Created: / 19.6.1998 / 01:34:58 / cg" |
|
2658 |
! |
|
2659 |
||
2660 |
showActivity:someMessage |
|
2661 |
"some activityNotification shalt be communicated to |
|
2662 |
the user. Forwarded from the topView and ignored here. |
|
2663 |
Can be redefined in concrete applications to show the |
|
2664 |
message either in some infoView (infoLabel as in Windows) |
|
2665 |
or in the title area (as done in the browsers)" |
|
2666 |
||
2667 |
^ self |
|
2668 |
||
2669 |
"Created: 16.12.1995 / 18:41:04 / cg" |
|
2670 |
"Modified: 24.4.1996 / 09:34:22 / cg" |
|
2671 |
! |
|
2672 |
||
2673 |
windowEvent:anEvent from:anApplicationWindow |
|
2674 |
"dummy: windowEvent forwarding is not yet implemented" |
|
2675 |
||
2676 |
^ self |
|
2677 |
||
2678 |
"Modified: 24.4.1996 / 09:32:50 / cg" |
|
2679 |
! ! |
|
2680 |
||
2681 |
!ApplicationModel class methodsFor:'documentation'! |
|
2682 |
||
1417 | 2683 |
version |
1634 | 2684 |
^ '$Header: /cvs/stx/stx/libview2/ApplicationModel.st,v 1.175 2002-10-17 11:24:43 cg Exp $' |
85 | 2685 |
! ! |
1633
07765ef65021
fix (kludge) for slaveApp, which have a masterApp,
Claus Gittinger <cg@exept.de>
parents:
1622
diff
changeset
|
2686 |
|
1419 | 2687 |
ApplicationModel initialize! |