author | Claus Gittinger <cg@exept.de> |
Sat, 27 Jan 1996 16:35:09 +0100 | |
changeset 385 | 15fd1c806d2a |
parent 328 | 7bbe05da5769 |
child 504 | bc7734000bd3 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
72 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
135 | 13 |
TopView subclass:#StandardSystemView |
328 | 14 |
instanceVariableNames:'label icon iconView iconLabel minExtent maxExtent sizeFixed |
15 |
application windowEventsForApplication' |
|
16 |
classVariableNames:'DefaultIcon TakeFocusWhenMapped IncludeHostNameInLabel' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Basic' |
|
0 | 19 |
! |
20 |
||
46 | 21 |
!StandardSystemView class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
72 | 26 |
All Rights Reserved |
0 | 27 |
|
46 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
0 | 36 |
|
46 | 37 |
documentation |
38 |
" |
|
39 |
I represent topViews i.e. those views which have a title-label, |
|
72 | 40 |
an icon etc. Usually StandardSystemViews are subclassed for |
41 |
special views. |
|
46 | 42 |
" |
43 |
! ! |
|
0 | 44 |
|
269 | 45 |
!StandardSystemView class methodsFor:'instance creation'! |
183 | 46 |
|
269 | 47 |
extent:anExtent label:aLabel icon:aForm |
48 |
"create a new topView and define its extent, label and icon" |
|
180 | 49 |
|
269 | 50 |
^ self origin:nil extent:anExtent |
51 |
label:aLabel icon:aForm |
|
52 |
minExtent:nil maxExtent:nil |
|
81 | 53 |
! |
54 |
||
269 | 55 |
extent:anExtent label:aLabel icon:aForm minExtent:minExtent |
56 |
^ self origin:nil extent:anExtent |
|
57 |
label:aLabel icon:aForm |
|
58 |
minExtent:minExtent maxExtent:nil |
|
46 | 59 |
! |
60 |
||
269 | 61 |
extent:anExtent label:aLabel icon:aForm minExtent:minExtent maxExtent:maxExtent |
62 |
^ self origin:nil extent:anExtent |
|
63 |
label:aLabel icon:aForm |
|
64 |
minExtent:minExtent maxExtent:maxExtent |
|
65 |
! |
|
0 | 66 |
|
269 | 67 |
extent:anExtent label:aLabel minExtent:minExtent |
68 |
"create a new topView and define its extent, label and minumum extent" |
|
0 | 69 |
|
269 | 70 |
^ self origin:nil extent:anExtent |
71 |
label:aLabel icon:nil |
|
72 |
minExtent:minExtent maxExtent:nil |
|
0 | 73 |
! |
74 |
||
75 |
label:aLabel |
|
76 |
"create a new topView and define its label" |
|
77 |
||
78 |
^ self origin:nil extent:nil |
|
72 | 79 |
label:aLabel icon:nil |
80 |
minExtent:nil maxExtent:nil |
|
0 | 81 |
! |
82 |
||
83 |
label:aLabel icon:aForm |
|
81 | 84 |
"create a new topView and define its label and icon" |
85 |
||
0 | 86 |
^ self origin:nil extent:nil |
72 | 87 |
label:aLabel icon:aForm |
88 |
minExtent:nil maxExtent:nil |
|
0 | 89 |
! |
90 |
||
91 |
label:aLabel icon:aForm minExtent:anExtent |
|
81 | 92 |
"create a new topView and define its label, icon and minumum extent" |
93 |
||
0 | 94 |
^ self origin:nil extent:nil |
72 | 95 |
label:aLabel icon:aForm |
96 |
minExtent:anExtent maxExtent:nil |
|
0 | 97 |
! |
98 |
||
99 |
label:aLabel icon:aForm minExtent:minExtent maxExtent:maxExtent |
|
81 | 100 |
"create a new topView and define its label, icon, min and max extents" |
101 |
||
0 | 102 |
^ self origin:nil extent:nil |
72 | 103 |
label:aLabel icon:aForm |
104 |
minExtent:minExtent maxExtent:maxExtent |
|
0 | 105 |
! |
106 |
||
269 | 107 |
label:aLabel minExtent:anExtent |
108 |
"create a new topView and define its label and minimum extent" |
|
109 |
||
110 |
^ self origin:nil extent:nil |
|
111 |
label:aLabel icon:nil |
|
112 |
minExtent:anExtent maxExtent:nil |
|
113 |
! |
|
114 |
||
115 |
model:aModel label:aLabel minimumSize:minExtent |
|
116 |
"ST80-style instance creation" |
|
117 |
||
118 |
|newView| |
|
119 |
||
120 |
newView := self origin:nil |
|
121 |
extent:minExtent |
|
122 |
label:aLabel |
|
123 |
icon:nil |
|
124 |
minExtent:minExtent |
|
125 |
maxExtent:nil. |
|
126 |
newView model:aModel. |
|
127 |
"/ newView controller:(self defaultControllerClass new view:newView). |
|
128 |
^ newView |
|
129 |
! |
|
130 |
||
0 | 131 |
origin:anOrigin extent:anExtent label:aLabel |
81 | 132 |
"create a new topView and define its origin, extent and label" |
133 |
||
0 | 134 |
^ self origin:anOrigin extent:anExtent |
72 | 135 |
label:aLabel icon:nil |
136 |
minExtent:nil maxExtent:nil |
|
0 | 137 |
! |
138 |
||
139 |
origin:anOrigin label:aLabel icon:aForm |
|
72 | 140 |
minExtent:minExtent maxExtent:maxExtent |
81 | 141 |
"create a new topView and define its origin, extent, label, icon |
142 |
and extent-boundaries." |
|
143 |
||
0 | 144 |
^ self origin:anOrigin extent:nil |
72 | 145 |
label:aLabel icon:aForm |
146 |
minExtent:minExtent maxExtent:maxExtent |
|
269 | 147 |
! ! |
148 |
||
149 |
!StandardSystemView class methodsFor:'defaults'! |
|
150 |
||
151 |
defaultIcon |
|
152 |
"return the default icon for views. |
|
153 |
This can be redefined in subclasses or overwritten in |
|
154 |
initialize methods." |
|
155 |
||
156 |
DefaultIcon isNil ifTrue:[ |
|
157 |
DefaultIcon := Image fromFile:'SmalltalkX.xbm'. |
|
158 |
DefaultIcon notNil ifTrue:[ |
|
159 |
DefaultIcon := DefaultIcon on:Display |
|
160 |
] |
|
161 |
]. |
|
162 |
^ DefaultIcon |
|
163 |
! |
|
164 |
||
165 |
defaultLabel |
|
166 |
"return the default label for views of my kind. |
|
167 |
This can be redefined in subclasses or overwritten in |
|
168 |
initialize methods." |
|
169 |
||
170 |
^ 'aView' |
|
171 |
! |
|
172 |
||
173 |
includeHostNameInLabel |
|
174 |
"return the flag which controls if a views label should |
|
175 |
include the hostname. |
|
176 |
This flag is usually set/cleared in your private.rc file; |
|
177 |
the default is false." |
|
178 |
||
179 |
^ IncludeHostNameInLabel |
|
180 |
||
181 |
"Created: 10.9.1995 / 19:21:16 / claus" |
|
182 |
! |
|
183 |
||
184 |
includeHostNameInLabel:aBoolean |
|
185 |
"set/clear the flag which controls if a views label should |
|
186 |
include the hostname - this is highly useful if you have |
|
187 |
multiple smalltalks open simultaniously ... |
|
188 |
This flag is usually set/cleared in your private.rc file; |
|
189 |
the default is false." |
|
190 |
||
191 |
IncludeHostNameInLabel := aBoolean |
|
192 |
! ! |
|
193 |
||
194 |
!StandardSystemView class methodsFor:'startup'! |
|
195 |
||
196 |
open |
|
197 |
"create, realize the view - this topview and all its subviews will |
|
198 |
run as a separate process with its own windowGroup" |
|
199 |
||
200 |
^ self new open |
|
201 |
! |
|
202 |
||
203 |
start |
|
204 |
"create, realize the view - this topview and all its subviews will |
|
205 |
run as a separate process with its own windowGroup. |
|
206 |
This method exists for backward compatibility - use open." |
|
207 |
||
208 |
^ self open |
|
209 |
! ! |
|
210 |
||
211 |
!StandardSystemView methodsFor:'accessing'! |
|
212 |
||
213 |
application |
|
214 |
"return the topViews application. |
|
215 |
This is new protocol for ST-80 compatibility and not yet fully supported" |
|
216 |
||
217 |
^ application |
|
218 |
! |
|
219 |
||
220 |
application:anApplicationModel |
|
221 |
"set the topViews application. |
|
222 |
This is new protocol for ST-80 compatibility and not yet fully supported" |
|
223 |
||
224 |
application := anApplicationModel |
|
225 |
! |
|
226 |
||
227 |
bePartner |
|
228 |
self setWindowGroupFromApplication. |
|
229 |
super bePartner. |
|
230 |
||
298 | 231 |
" |
232 |
see example in TopView>>bePartner |
|
233 |
" |
|
234 |
||
269 | 235 |
"Created: 22.9.1995 / 17:40:15 / claus" |
298 | 236 |
"Modified: 10.12.1995 / 13:30:36 / cg" |
269 | 237 |
! |
238 |
||
239 |
beSlave |
|
240 |
self setWindowGroupFromApplication. |
|
241 |
super beSlave. |
|
242 |
||
298 | 243 |
" |
244 |
see example in TopView>>beSlave |
|
245 |
" |
|
246 |
||
269 | 247 |
"Created: 22.9.1995 / 17:40:15 / claus" |
298 | 248 |
"Modified: 10.12.1995 / 13:24:51 / cg" |
269 | 249 |
! |
250 |
||
251 |
icon |
|
252 |
"return the form defined as icon" |
|
253 |
||
254 |
^ icon |
|
0 | 255 |
! |
256 |
||
269 | 257 |
icon:aForm |
258 |
"define the form (bitmap) used as icon" |
|
259 |
||
260 |
|invertedIcon i| |
|
261 |
||
262 |
icon := aForm. |
|
263 |
icon notNil ifTrue:[ |
|
264 |
drawableId notNil ifTrue:[ |
|
265 |
icon depth ~~ 1 ifTrue:[ |
|
266 |
icon := icon asMonochromeFormOn:device. |
|
267 |
]. |
|
268 |
"icons assume 1s as black - invert icon if the device thinks different" |
|
269 |
(device depth == 1 and:[device whitepixel ~~ 0]) ifTrue:[ |
|
270 |
i := icon on:device. |
|
271 |
i notNil ifTrue:[ |
|
272 |
invertedIcon := Form width:icon width height:icon height on:device. |
|
273 |
invertedIcon function:#copy. |
|
274 |
invertedIcon foreground:Color noColor background:Color allColor. |
|
275 |
invertedIcon copyFrom:i x:0 y:0 toX:0 y:0 width:icon width height:icon height. |
|
276 |
i := invertedIcon. |
|
277 |
] |
|
278 |
] ifFalse:[ |
|
279 |
i := icon on:device. |
|
280 |
]. |
|
281 |
(i notNil and:[i id notNil]) ifTrue:[ |
|
282 |
device setWindowIcon:i in:drawableId |
|
283 |
] |
|
284 |
] |
|
285 |
] |
|
286 |
! |
|
287 |
||
288 |
iconLabel |
|
289 |
"return the name displayed in the icon" |
|
290 |
||
291 |
^ iconLabel |
|
292 |
! |
|
293 |
||
294 |
iconLabel:aString |
|
295 |
"define the name to be displayed in the icon" |
|
296 |
||
297 |
iconLabel := aString. |
|
298 |
drawableId notNil ifTrue:[ |
|
299 |
device setIconName:aString in:drawableId. |
|
300 |
" |
|
301 |
unbuffered - to make it visible right NOW |
|
302 |
" |
|
303 |
device flush. |
|
304 |
] |
|
305 |
! |
|
81 | 306 |
|
269 | 307 |
iconName:aString |
308 |
"this method will vanish soon ... - for backward compatibility" |
|
309 |
||
310 |
self iconLabel:aString |
|
311 |
! |
|
312 |
||
313 |
iconView |
|
314 |
"return the view used as icon-view" |
|
315 |
||
316 |
^ iconView |
|
317 |
! |
|
318 |
||
319 |
iconView:aView |
|
320 |
"specify the view to be used as icon" |
|
321 |
||
322 |
iconView := aView. |
|
323 |
drawableId notNil ifTrue:[ |
|
324 |
aView create. |
|
325 |
device setWindowIconWindow:aView in:drawableId |
|
326 |
] |
|
327 |
! |
|
328 |
||
329 |
label |
|
330 |
"return the views name in the title area" |
|
331 |
||
332 |
^ label |
|
333 |
! |
|
334 |
||
335 |
label:aString |
|
336 |
"define the views name in the windows title area. |
|
337 |
If IncludeHostNameInLabel is true, prepend the hostname |
|
338 |
(you will appreciate this, if you are working on multiple |
|
339 |
machines simultanously - as I do ...)" |
|
340 |
||
341 |
|l| |
|
342 |
||
343 |
aString ~= label ifTrue:[ |
|
344 |
label := aString. |
|
345 |
drawableId notNil ifTrue: [ |
|
346 |
IncludeHostNameInLabel == true ifTrue:[ |
|
347 |
l := OperatingSystem getHostName , ': ' , aString. |
|
348 |
] ifFalse:[ |
|
349 |
l := aString |
|
350 |
]. |
|
351 |
device setWindowName:l in:drawableId. |
|
352 |
" |
|
353 |
unbuffered - to make it visible right NOW |
|
354 |
" |
|
355 |
device flush. |
|
356 |
] |
|
357 |
] |
|
358 |
||
359 |
"Created: 8.9.1995 / 19:37:06 / claus" |
|
360 |
"Modified: 8.9.1995 / 19:39:18 / claus" |
|
0 | 361 |
! |
362 |
||
269 | 363 |
label:labelString iconLabel:iconLabelString |
364 |
"set both the label and the iconLabel" |
|
365 |
||
366 |
self label:labelString. |
|
367 |
self iconLabel:iconLabelString |
|
368 |
! |
|
369 |
||
370 |
maxExtent |
|
371 |
"return the views maximum allowed extent" |
|
372 |
||
373 |
^ maxExtent |
|
374 |
! |
|
375 |
||
376 |
maxExtent:max |
|
377 |
"define the maximum extent the view may have - |
|
378 |
depends on good-will of window manager" |
|
379 |
||
380 |
maxExtent := max. |
|
381 |
(width notNil and:[height notNil]) ifTrue:[ |
|
382 |
((width > (maxExtent x)) or: |
|
383 |
[height > (maxExtent y)]) ifTrue: [ |
|
384 |
self extent:maxExtent |
|
385 |
] |
|
386 |
] |
|
387 |
! |
|
388 |
||
389 |
maximumSize:anExtent |
|
390 |
"same as maxExtent: for ST-80 compatibility" |
|
391 |
||
392 |
^ self maxExtent:anExtent |
|
393 |
! |
|
81 | 394 |
|
269 | 395 |
minExtent |
396 |
"return the views minimum allowed extent" |
|
397 |
||
398 |
^ minExtent |
|
399 |
! |
|
400 |
||
401 |
minExtent:min |
|
402 |
"define the minimum extent the view may have - |
|
403 |
depends on good-will of window manager" |
|
404 |
||
405 |
minExtent := min. |
|
406 |
(width notNil and:[height notNil]) ifTrue:[ |
|
407 |
((width < (minExtent x)) or: |
|
408 |
[height < (minExtent y)]) ifTrue: [ |
|
409 |
self extent:minExtent |
|
410 |
] |
|
411 |
] |
|
412 |
! |
|
413 |
||
414 |
minimumSize |
|
415 |
"same as minExtent for ST-80 compatibility" |
|
416 |
||
417 |
^ self minExtent |
|
418 |
! |
|
419 |
||
420 |
minimumSize:anExtent |
|
421 |
"same as minExtent: for ST-80 compatibility" |
|
422 |
||
423 |
^ self minExtent:anExtent |
|
424 |
! |
|
425 |
||
426 |
name |
|
427 |
"return the topViews label" |
|
428 |
||
429 |
^ label |
|
0 | 430 |
! |
431 |
||
269 | 432 |
sizeFixed:aBoolean |
433 |
"this prevents the view from resizing itself when realized. |
|
434 |
For normal topViews, this is void, since they dont do this anyway. |
|
435 |
||
436 |
However, modalBoxes (especially: DialogBoxes) typically resize themselfes |
|
437 |
to the preferredExtent of their components. In some cases, this behavior is |
|
438 |
not desired and it should be turned off by setting sizeFixed to true. |
|
439 |
||
440 |
To avoid confusion: |
|
441 |
This does NOT prevent the window manager from resizing the view, |
|
442 |
instead it tells the view to NOT resize ITSELF." |
|
443 |
||
444 |
sizeFixed := aBoolean. |
|
445 |
||
446 |
"example: dialog which resizes itself on #open: |
|
447 |
(thereby ignoring the 200@200 extent) |
|
448 |
||
449 |
|dialog| |
|
450 |
||
451 |
dialog := Dialog new. |
|
452 |
dialog addInputFieldOn:'' asValue. |
|
453 |
dialog addOkButton. |
|
454 |
dialog extent:200@200. |
|
455 |
dialog open. |
|
456 |
||
457 |
||
458 |
using sizeFixed: |
|
459 |
||
460 |
|dialog| |
|
461 |
||
462 |
dialog := Dialog new. |
|
463 |
dialog addInputFieldOn:'' asValue. |
|
464 |
dialog addOkButton. |
|
465 |
dialog extent:200@200; sizeFixed:true. |
|
466 |
dialog open. |
|
467 |
||
468 |
||
469 |
using openWithExtent (also sets sizeFixed): |
|
470 |
||
471 |
|dialog| |
|
472 |
||
473 |
dialog := Dialog new. |
|
474 |
dialog addInputFieldOn:'' asValue. |
|
475 |
dialog addOkButton. |
|
476 |
dialog openWithExtent:200@200. |
|
477 |
" |
|
478 |
! ! |
|
479 |
||
480 |
!StandardSystemView methodsFor:'destroying'! |
|
481 |
||
482 |
closeRequest |
|
483 |
"programmatic close request" |
|
484 |
||
485 |
^ self terminate |
|
486 |
! |
|
487 |
||
488 |
destroy |
|
489 |
"destroy the view." |
|
490 |
||
491 |
self removeFromCurrentProject. |
|
492 |
windowGroup notNil ifTrue:[ |
|
493 |
windowGroup focusSequence:nil. |
|
494 |
]. |
|
495 |
application notNil ifTrue:[ |
|
496 |
application windowEvent:(#close -> self) from:self |
|
497 |
]. |
|
498 |
super destroy. |
|
0 | 499 |
! |
500 |
||
269 | 501 |
saveAndTerminate |
502 |
"save & terminate request from the windowManager. The application should |
|
503 |
save its data/files/text etc. somehow and close. |
|
504 |
If there is an application, let it decide how do do that. |
|
505 |
Otherwise, forward it to superclasses which knows how to do this. |
|
506 |
(it defaults to a terminate there). |
|
507 |
Notice, that not all windowmanagers are nice enough |
|
508 |
to send this request; some simply distroy the view." |
|
509 |
||
510 |
application notNil ifTrue:[ |
|
511 |
application saveAndTerminateRequest |
|
512 |
] ifFalse:[ |
|
513 |
super saveAndTerminate |
|
514 |
] |
|
515 |
! |
|
516 |
||
517 |
terminate |
|
518 |
"terminate request from the windowManager. If there is an application, |
|
519 |
let it decide if it really wants to be close. Otherwise, forward it to |
|
520 |
superclasses terminate which knows how to do this. |
|
521 |
Notice, that not all windowmanagers are nice enough |
|
522 |
to send this request; some simply distroy the view." |
|
523 |
||
524 |
application notNil ifTrue:[ |
|
525 |
application closeRequest |
|
526 |
] ifFalse:[ |
|
527 |
super terminate |
|
528 |
] |
|
529 |
! ! |
|
530 |
||
531 |
!StandardSystemView methodsFor:'event handling'! |
|
532 |
||
533 |
focusIn |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
534 |
"the view got the keyboard focus (via the window manager)" |
269 | 535 |
|
536 |
|v| |
|
537 |
||
538 |
windowGroup notNil ifTrue:[ |
|
539 |
(v := windowGroup focusView) notNil ifTrue:[ |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
540 |
v showFocus:false. |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
541 |
^ self |
269 | 542 |
] |
543 |
]. |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
544 |
delegate notNil ifTrue:[ |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
545 |
delegate showFocus:false. |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
546 |
] |
269 | 547 |
! |
548 |
||
549 |
focusOut |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
550 |
"the view lost keyboard focus (via the window manager)" |
269 | 551 |
|
552 |
|v| |
|
553 |
||
554 |
windowGroup notNil ifTrue:[ |
|
555 |
(v := windowGroup focusView) notNil ifTrue:[ |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
556 |
v showNoFocus:false. |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
557 |
^ self |
269 | 558 |
] |
559 |
]. |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
560 |
delegate notNil ifTrue:[ |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
561 |
delegate showNoFocus:false. |
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
562 |
] |
269 | 563 |
! |
564 |
||
565 |
mapped |
|
566 |
"the view got mapped" |
|
567 |
||
568 |
super mapped. |
|
569 |
" |
|
570 |
ask for the focus - this avoids having to click on the |
|
571 |
view with WM's which need an explicit click. |
|
572 |
Q: is this a good idea ? |
|
573 |
" |
|
574 |
TakeFocusWhenMapped == true ifTrue:[ |
|
575 |
self getKeyboardFocus. |
|
576 |
] |
|
577 |
! |
|
578 |
||
579 |
sendWindowEvents:collectionOfEventSymbols |
|
580 |
"define the events that are to be forwarded to the application. |
|
581 |
This is being implemented ..." |
|
582 |
||
583 |
windowEventsForApplication := collectionOfEventSymbols |
|
328 | 584 |
! |
585 |
||
586 |
showActivity:someMessage |
|
587 |
application notNil ifTrue:[ |
|
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
588 |
application showActivity:someMessage |
328 | 589 |
] |
590 |
||
591 |
"Created: 16.12.1995 / 18:40:44 / cg" |
|
0 | 592 |
! ! |
593 |
||
594 |
!StandardSystemView methodsFor:'initialization'! |
|
595 |
||
596 |
addToCurrentProject |
|
46 | 597 |
"add the receiver (a topview) to the current projects set-of-views. |
598 |
(If there is a current project)" |
|
599 |
||
72 | 600 |
|p| |
69 | 601 |
|
602 |
" |
|
72 | 603 |
the following check allows systems |
604 |
without projects and changeSets |
|
69 | 605 |
" |
72 | 606 |
(Project notNil and:[(p := Project current) notNil]) ifTrue:[ |
607 |
p addView: self |
|
69 | 608 |
] |
609 |
! |
|
12 | 610 |
|
269 | 611 |
defaultControllerClass |
612 |
"for ST-80 compatibility only - not used in ST/X" |
|
613 |
||
614 |
^ nil "/ StandardSystemController |
|
615 |
! |
|
616 |
||
617 |
initEvents |
|
618 |
super initEvents. |
|
619 |
self enableFocusEvents. |
|
620 |
! |
|
621 |
||
622 |
initialize |
|
623 |
super initialize. |
|
69 | 624 |
|
269 | 625 |
borderWidth := 2. "- notice: many window managers ignore this" |
626 |
minExtent := 10 @ 10. |
|
627 |
maxExtent := (device width) @ (device height). |
|
628 |
label isNil ifTrue:[label := self class defaultLabel]. |
|
629 |
icon isNil ifTrue:[icon := self class defaultIcon]. |
|
630 |
name := self class name. |
|
631 |
! |
|
632 |
||
633 |
reAdjustGeometry |
|
634 |
"when we come up on a smaller display, |
|
635 |
make certain, that the receiver is visible" |
|
636 |
||
637 |
|dX dY limitRight limitBottom| |
|
638 |
||
639 |
dX := (device horizontalPixelPerMillimeter * 20) rounded. |
|
640 |
dY := (device verticalPixelPerMillimeter * 20) rounded. |
|
69 | 641 |
|
269 | 642 |
limitRight := device width - dX. |
643 |
limitBottom := device height - dY. |
|
644 |
((self left > limitRight) or:[ |
|
645 |
self top > limitBottom]) ifTrue:[ |
|
646 |
'moving view into visible area' errorPrintNL. |
|
647 |
self origin:limitRight @ limitBottom |
|
648 |
] |
|
649 |
! |
|
650 |
||
651 |
realize |
|
652 |
"realize the view i.e. make it visible." |
|
653 |
||
654 |
super realize. |
|
655 |
windowGroup notNil ifTrue:[ |
|
656 |
"/ |
|
657 |
"/ have to wait till now with focus-setting, |
|
658 |
"/ up to now, I may have had no windowGroup (its set in realize) |
|
659 |
"/ |
|
660 |
windowGroup focusSequence:self focusSequence. |
|
661 |
"/ |
|
662 |
"/ let the application add its views to the current project |
|
663 |
"/ |
|
664 |
application notNil ifTrue:[ |
|
665 |
application opened. |
|
666 |
] ifFalse:[ |
|
667 |
self addToCurrentProject. |
|
668 |
]. |
|
669 |
] |
|
670 |
! |
|
671 |
||
672 |
recreate |
|
673 |
"recreate the view after a snap-in" |
|
674 |
||
675 |
icon := self convertedIcon. |
|
676 |
super recreate. |
|
677 |
||
678 |
iconView notNil ifTrue:[ |
|
679 |
iconView create. |
|
680 |
device setWindowIconWindow:iconView in:drawableId |
|
681 |
] ifFalse:[ |
|
682 |
(icon notNil and:[icon id notNil]) ifTrue:[ |
|
683 |
device setWindowIcon:icon in:drawableId |
|
684 |
]. |
|
685 |
]. |
|
686 |
||
687 |
iconLabel notNil ifTrue:[ |
|
688 |
device setIconName:iconLabel in:drawableId |
|
12 | 689 |
] |
0 | 690 |
! |
691 |
||
24 | 692 |
reinitialize |
46 | 693 |
"reopen the receiver if if was visible before. |
694 |
This is called right after snapIn; Notice, that all instance variables |
|
72 | 695 |
(such as shown, realized etc.) are left-overs from the time the snapout |
46 | 696 |
was done. Remap the receiver, if it was mapped at snapout time" |
24 | 697 |
|
698 |
|myController| |
|
699 |
||
700 |
"if I have already been reinited - return" |
|
701 |
drawableId notNil ifTrue:[ |
|
72 | 702 |
^ self |
24 | 703 |
]. |
704 |
||
46 | 705 |
"have to kludge with the controller |
706 |
- otherwise its startup performs unwanted actions ..." |
|
707 |
||
24 | 708 |
myController := controller. |
709 |
controller := nil. |
|
46 | 710 |
|
711 |
"physically create the view & subviews" |
|
24 | 712 |
self recreate. |
713 |
||
714 |
"if I was mapped, do it again" |
|
715 |
realized ifTrue:[ |
|
72 | 716 |
"if it was iconified, try to remap iconified" |
89 | 717 |
device mapView:self id:drawableId iconified:(shown not) |
718 |
atX:left y:top width:width height:height. |
|
24 | 719 |
|
72 | 720 |
"and restart the window-group process" |
721 |
windowGroup notNil ifTrue:[ |
|
722 |
windowGroup restart |
|
723 |
] |
|
24 | 724 |
]. |
725 |
||
726 |
"restore controller" |
|
727 |
controller := myController |
|
728 |
! |
|
729 |
||
269 | 730 |
removeFromCurrentProject |
731 |
"remove the receiver (a topview) from the current projects set-of-views. |
|
732 |
(If there is a current project)" |
|
46 | 733 |
|
269 | 734 |
|p| |
12 | 735 |
|
269 | 736 |
" |
737 |
the following check allows systems |
|
738 |
without projects and changeSets |
|
739 |
" |
|
740 |
(Project notNil and:[(p := Project current) notNil]) ifTrue:[ |
|
741 |
p removeView:self |
|
89 | 742 |
] |
743 |
! |
|
744 |
||
140 | 745 |
restarted |
746 |
"sent by my windowGroup, when restarted from an image. |
|
747 |
Nothing done here, but can be redefined to perform any actions |
|
748 |
required to reset the application after an image-restart. |
|
749 |
(for example: check if application files are still around, restart |
|
750 |
subprocesses etc.)." |
|
751 |
||
752 |
application notNil ifTrue:[ |
|
753 |
application restarted |
|
754 |
]. |
|
0 | 755 |
! ! |
756 |
||
269 | 757 |
!StandardSystemView methodsFor:'printing & storing'! |
142 | 758 |
|
269 | 759 |
displayString |
760 |
"just for your convenience in inspectors ... |
|
761 |
... add the views label to the displayString." |
|
142 | 762 |
|
269 | 763 |
|s| |
142 | 764 |
|
269 | 765 |
s := super displayString. |
766 |
label notNil ifTrue:[ |
|
767 |
s := s , '(' , label , ')' |
|
157 | 768 |
]. |
269 | 769 |
^ s |
0 | 770 |
! ! |
771 |
||
24 | 772 |
!StandardSystemView methodsFor:'private'! |
773 |
||
774 |
convertedIcon |
|
775 |
"make certain, that the icon is a b&w bitmap; |
|
72 | 776 |
do so by converting if required. |
24 | 777 |
Will add a device supportsDeepIcons and only convert when needed; |
72 | 778 |
for now, we always have to convert (since there are only Xdisplays)." |
24 | 779 |
|
780 |
|deviceIcon| |
|
781 |
||
782 |
icon isNil ifTrue:[^ nil]. |
|
783 |
||
81 | 784 |
device supportsDeepIcons ifFalse:[ |
785 |
icon depth ~~ 1 ifTrue:[ |
|
786 |
" |
|
787 |
dither to monochrome |
|
788 |
" |
|
789 |
deviceIcon := icon asMonochromeFormOn:device. |
|
790 |
] ifFalse:[ |
|
791 |
deviceIcon := icon |
|
792 |
] |
|
24 | 793 |
]. |
794 |
deviceIcon notNil ifTrue:[ |
|
81 | 795 |
" |
796 |
get device pixmap (i.e. allocate colors & resource) |
|
797 |
" |
|
72 | 798 |
deviceIcon := deviceIcon on:device |
24 | 799 |
]. |
800 |
^ deviceIcon |
|
193 | 801 |
! |
802 |
||
803 |
setWindowGroupFromApplication |
|
804 |
|win| |
|
805 |
||
806 |
windowGroup isNil ifTrue:[ |
|
807 |
application notNil ifTrue:[ |
|
808 |
(win := application window) notNil ifTrue:[ |
|
809 |
windowGroup := win windowGroup. |
|
810 |
] |
|
811 |
] |
|
812 |
]. |
|
813 |
||
814 |
"Created: 22.9.1995 / 17:40:36 / claus" |
|
24 | 815 |
! ! |
816 |
||
269 | 817 |
!StandardSystemView methodsFor:'queries'! |
818 |
||
819 |
focusSequence |
|
820 |
"return a sequence which defines the order in which the focus |
|
821 |
is passed for FocusNext and FocusPrevious keys. |
|
822 |
All views which like to support these keys should redefine |
|
823 |
this method and return a collection of (sub-) views. |
|
824 |
Or, if the model is some applicationModel, it may itself define |
|
825 |
the focusSequence. |
|
826 |
Notice: I dont think this is good style: the focusSequence seems |
|
827 |
to belong into the controller, ..." |
|
828 |
||
829 |
"/ |
|
830 |
"/ if I have an application, its supposed to |
|
831 |
"/ know about the focusSequence |
|
832 |
"/ |
|
833 |
application notNil ifTrue:[ |
|
834 |
^ application focusSequence |
|
835 |
]. |
|
836 |
||
837 |
(model notNil |
|
838 |
and:[(model respondsTo:#focusSequence) |
|
839 |
and:[model ~~ self]]) ifTrue:[ |
|
840 |
^ model focusSequence |
|
841 |
]. |
|
842 |
^ nil |
|
843 |
! |
|
844 |
||
298 | 845 |
isModal |
846 |
windowGroup isNil ifTrue:[^ false]. |
|
847 |
^ windowGroup isModal |
|
848 |
||
849 |
"Created: 10.12.1995 / 13:11:17 / cg" |
|
850 |
! |
|
851 |
||
269 | 852 |
processName |
853 |
"return a string to be shown for my process in the |
|
854 |
process monitor" |
|
855 |
||
856 |
application notNil ifTrue:[ |
|
857 |
^ application processName |
|
858 |
]. |
|
859 |
label notNil ifTrue:[^ label]. |
|
860 |
^ super processName |
|
861 |
! ! |
|
862 |
||
0 | 863 |
!StandardSystemView methodsFor:'realization'! |
864 |
||
269 | 865 |
create |
866 |
"create - make certain that icon is available" |
|
867 |
||
868 |
icon := self convertedIcon. |
|
869 |
super create. |
|
870 |
||
871 |
iconView notNil ifTrue:[ |
|
872 |
iconView create. |
|
873 |
device setWindowIconWindow:iconView in:drawableId |
|
874 |
]. |
|
875 |
iconLabel notNil ifTrue:[ |
|
876 |
device setIconName:iconLabel in:drawableId |
|
877 |
] |
|
878 |
! |
|
879 |
||
880 |
openWithPriority:aPriority |
|
881 |
"open the view, run the windowgroup process at |
|
882 |
other than UserScehdulingPriority." |
|
883 |
||
884 |
self open. |
|
885 |
windowGroup process priority:aPriority. |
|
886 |
! |
|
887 |
||
46 | 888 |
physicalCreate |
889 |
"common code for create & recreate" |
|
890 |
||
183 | 891 |
|l| |
892 |
||
893 |
IncludeHostNameInLabel == true ifTrue:[ |
|
894 |
l := OperatingSystem getHostName , ': ' , label. |
|
895 |
] ifFalse:[ |
|
896 |
l := label |
|
897 |
]. |
|
898 |
||
46 | 899 |
drawableId := device |
72 | 900 |
createWindowFor:self |
901 |
origin:(left @ top) |
|
902 |
extent:(width @ height) |
|
903 |
minExtent:minExtent |
|
904 |
maxExtent:maxExtent |
|
905 |
borderWidth:borderWidth |
|
906 |
subViewOf:nil |
|
157 | 907 |
onTop:(self isPopUpView) |
72 | 908 |
inputOnly:(self inputOnly) |
183 | 909 |
label:l |
72 | 910 |
cursor:cursor |
911 |
icon:icon |
|
912 |
iconView:iconView. |
|
46 | 913 |
|
914 |
extentChanged := false. |
|
915 |
originChanged := false. |
|
916 |
||
81 | 917 |
(borderColor notNil and:[borderColor ~~ Black]) ifTrue:[ |
918 |
borderColor := borderColor on:device. |
|
919 |
self setBorderColor |
|
72 | 920 |
]. |
81 | 921 |
|
922 |
"/ (viewGravity notNil "and:[viewGravity ~~ #NorthWest]") ifTrue:[ |
|
923 |
"/ device setWindowGravity:viewGravity in:drawableId |
|
924 |
"/ ]. |
|
925 |
||
926 |
"/ (bitGravity notNil "and:[bitGravity ~~ #NorthWest]") ifTrue:[ |
|
927 |
"/ device setBitGravity:bitGravity in:drawableId |
|
928 |
"/ ]. |
|
72 | 929 |
|
46 | 930 |
borderShape notNil ifTrue:[ |
72 | 931 |
device setWindowBorderShape:(borderShape id) in:drawableId |
46 | 932 |
]. |
933 |
viewShape notNil ifTrue:[ |
|
72 | 934 |
device setWindowShape:(viewShape id) in:drawableId |
46 | 935 |
]. |
936 |
(backed notNil and:[backed ~~ false]) ifTrue:[ |
|
72 | 937 |
device setBackingStore:backed in:drawableId |
46 | 938 |
]. |
939 |
saveUnder ifTrue:[ |
|
72 | 940 |
device setSaveUnder:true in:drawableId |
46 | 941 |
]. |
141 | 942 |
! ! |
943 |
||
269 | 944 |
!StandardSystemView class methodsFor:'documentation'! |
0 | 945 |
|
269 | 946 |
version |
385
15fd1c806d2a
pass info if focus change was explicit (i.e. Tab-key) or by window manager.
Claus Gittinger <cg@exept.de>
parents:
328
diff
changeset
|
947 |
^ '$Header: /cvs/stx/stx/libview/Attic/StdSysV.st,v 1.40 1996-01-27 15:35:07 cg Exp $' |
0 | 948 |
! ! |