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