author | Claus Gittinger <cg@exept.de> |
Sat, 16 Dec 1995 18:44:01 +0100 | |
changeset 328 | 7bbe05da5769 |
parent 314 | de706ed62d27 |
child 361 | 4ac325d9125b |
permissions | -rw-r--r-- |
135 | 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 |
View subclass:#TopView |
|
314
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
14 |
instanceVariableNames:'type' |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
15 |
classVariableNames:'' |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
16 |
poolDictionaries:'' |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
17 |
category:'Views-Basic' |
135 | 18 |
! |
19 |
||
20 |
!TopView class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
I am an abstract superclass of StandardSystemView and PopUpView; |
|
39 |
i.e. views which have no superview. |
|
40 |
" |
|
41 |
! ! |
|
42 |
||
43 |
!TopView class methodsFor:'defaults'! |
|
44 |
||
45 |
defaultExtent |
|
46 |
"topviews extent is (0.6 @ 0.6) of screen by default" |
|
47 |
||
153 | 48 |
|display| |
49 |
||
50 |
display := Screen current. |
|
51 |
^ (display width // 3 * 2) @ (display height // 3 * 2) |
|
135 | 52 |
! ! |
53 |
||
269 | 54 |
!TopView methodsFor:'accessing & queries'! |
55 |
||
56 |
beMaster |
|
57 |
"make this a master-view. All slave views within the same |
|
58 |
windowGroup will be closed if any master is closed." |
|
59 |
||
60 |
type := #master |
|
298 | 61 |
|
62 |
" |
|
63 |
see example in TopView>>beSlave |
|
64 |
" |
|
65 |
||
66 |
"Created: 10.12.1995 / 13:30:50 / cg" |
|
269 | 67 |
! |
68 |
||
69 |
bePartner |
|
70 |
"make this a partner-view. Each partner-view will automatically |
|
71 |
close other partner views whenclosed." |
|
72 |
||
73 |
type := #partner |
|
298 | 74 |
|
75 |
" |
|
76 |
create two topViews within the same group: |
|
77 |
if any of them is iconified/deiconified/closed, the other one is also |
|
78 |
||
79 |
|top1 top2| |
|
80 |
||
81 |
top1 := StandardSystemView new label:'top1'; extent:300@300. |
|
82 |
top2 := StandardSystemView new label:'top2'; extent:200@200. |
|
83 |
top1 bePartner. |
|
84 |
top2 bePartner. |
|
85 |
||
86 |
top1 open. |
|
87 |
top2 openInGroup:(top1 windowGroup) |
|
88 |
" |
|
89 |
||
90 |
"Created: 10.12.1995 / 13:29:59 / cg" |
|
269 | 91 |
! |
92 |
||
93 |
beSlave |
|
94 |
"make this a slave-view. It will be closed automatically, |
|
95 |
whenever any master of the group is closed." |
|
96 |
||
97 |
type := #slave |
|
298 | 98 |
|
99 |
" |
|
100 |
create two topViews within the same group: |
|
101 |
the slave is allowed to be iconified/close independ of the master; |
|
102 |
but if the master is iconified, the slave is also. |
|
103 |
||
104 |
|top1 top2| |
|
105 |
||
106 |
top1 := StandardSystemView new label:'top1'; extent:300@300. |
|
107 |
top2 := StandardSystemView new label:'top2'; extent:200@200. |
|
108 |
top1 beMaster. |
|
109 |
top2 beSlave. |
|
110 |
||
111 |
top1 open. |
|
112 |
top2 openInGroup:(top1 windowGroup) |
|
113 |
" |
|
114 |
||
115 |
"Created: 10.12.1995 / 13:29:10 / cg" |
|
269 | 116 |
! |
117 |
||
118 |
heightIncludingBorder |
|
119 |
"return the views overall-height" |
|
120 |
||
121 |
^ height |
|
122 |
! |
|
123 |
||
124 |
isCollapsed |
|
125 |
"ST80 compatibility: return true if the view is not shown (i.e. iconified)" |
|
126 |
||
127 |
^ shown not |
|
128 |
! |
|
129 |
||
130 |
preferredExtent |
|
131 |
"return my preferred extent - this is the minimum size I would like to have. |
|
132 |
The default here is the classes default extent, |
|
133 |
however many subclasses redefine this to compute the actual value |
|
134 |
depending on the sizes of the contents or subcomponents." |
|
135 |
||
136 |
^ self class defaultExtent |
|
137 |
! |
|
138 |
||
139 |
type |
|
140 |
"return the views type. This is one of #normal, |
|
141 |
#master, #slave or #partner." |
|
142 |
||
143 |
^ type |
|
144 |
! |
|
145 |
||
146 |
widthIncludingBorder |
|
147 |
"return the views overall-width" |
|
148 |
||
149 |
^ width |
|
150 |
! ! |
|
151 |
||
135 | 152 |
!TopView methodsFor:'initialization'! |
153 |
||
154 |
initialize |
|
155 |
|screenCenter| |
|
156 |
||
157 |
super initialize. |
|
158 |
||
159 |
screenCenter := device center. |
|
160 |
left := screenCenter x - (width // 2). |
|
161 |
top := screenCenter y - (height // 2). |
|
141 | 162 |
type := #normal |
135 | 163 |
! ! |
164 |
||
269 | 165 |
!TopView methodsFor:'misc'! |
166 |
||
167 |
raiseDeiconified |
|
168 |
"deiconify & bring to front" |
|
169 |
||
170 |
self isCollapsed ifTrue:[ |
|
171 |
self unrealize. |
|
172 |
self realize. |
|
173 |
]. |
|
174 |
self raise |
|
175 |
||
176 |
" |
|
177 |
Transcript topView raiseDeiconified |
|
178 |
" |
|
179 |
! |
|
180 |
||
328 | 181 |
showActivity:someMessage |
182 |
^ self |
|
183 |
||
184 |
"Created: 16.12.1995 / 18:40:13 / cg" |
|
185 |
! |
|
186 |
||
269 | 187 |
withCursor:aCursor do:aBlock |
188 |
"evaluate aBlock while showing aCursor in all my views. |
|
189 |
Return the value as returned by aBlock." |
|
190 |
||
191 |
windowGroup notNil ifTrue:[ |
|
192 |
^ windowGroup withCursor:aCursor do:aBlock |
|
193 |
]. |
|
194 |
^ super withCursor:aCursor do:aBlock |
|
195 |
! |
|
196 |
||
314
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
197 |
withExecuteCursorDo:aBlock |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
198 |
"evaluate aBlock while showing an execute cursor in all my views. |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
199 |
Return the value as returned by aBlock." |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
200 |
|
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
201 |
^ self withCursor:(Cursor execute) do:aBlock |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
202 |
|
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
203 |
"Created: 14.12.1995 / 20:57:22 / cg" |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
204 |
! |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
205 |
|
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
206 |
withReadCursorDo:aBlock |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
207 |
"evaluate aBlock while showing a readCursor in all my views. |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
208 |
Return the value as returned by aBlock." |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
209 |
|
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
210 |
^ self withCursor:(Cursor read) do:aBlock |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
211 |
|
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
212 |
"Created: 14.12.1995 / 20:56:38 / cg" |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
213 |
"Modified: 14.12.1995 / 20:57:40 / cg" |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
214 |
! |
de706ed62d27
added withReadCursorDo: / withExecuteCursorDo:
Claus Gittinger <cg@exept.de>
parents:
298
diff
changeset
|
215 |
|
269 | 216 |
withWaitCursorDo:aBlock |
217 |
"evaluate aBlock while showing a waitCursor in all my views. |
|
218 |
Return the value as returned by aBlock." |
|
219 |
||
220 |
^ self withCursor:(Cursor wait) do:aBlock |
|
221 |
! ! |
|
222 |
||
223 |
!TopView methodsFor:'startup'! |
|
224 |
||
225 |
openInGroup:aGroup |
|
226 |
"special open within another windowGroup. |
|
227 |
This allows a view to be realized in any windowgroup; |
|
228 |
for applications where multiple views act as a group |
|
229 |
(i.e. close and iconify together)." |
|
230 |
||
231 |
self windowGroup:aGroup. |
|
232 |
aGroup addTopView:self. |
|
233 |
self realizeLeavingGroup:true |
|
234 |
! |
|
235 |
||
236 |
openWithExtent:anExtent |
|
237 |
"set extent and open. The given extent overrides the |
|
238 |
receivers preferredExtent. |
|
239 |
Added for ST-80 compatibility" |
|
240 |
||
241 |
self extent:anExtent; sizeFixed:true. |
|
242 |
self open |
|
243 |
! ! |
|
244 |
||
157 | 245 |
!TopView methodsFor:'window events'! |
246 |
||
247 |
destroy |
|
248 |
"the receiver is to be destroyed - look for partners and slaves" |
|
249 |
||
250 |
|wg| |
|
251 |
||
252 |
wg := windowGroup. "/ have to fetch windowGroup before; |
|
253 |
super destroy. "/ since destroy nils it |
|
254 |
wg notNil ifTrue:[ |
|
255 |
"/ |
|
256 |
"/ if I am a master or partner, close all slaves |
|
257 |
"/ |
|
258 |
(type == #master or:[type == #partner]) ifTrue:[ |
|
259 |
wg slavesDo:[:v | v destroy]. |
|
260 |
]. |
|
261 |
"/ |
|
262 |
"/ if I am a partner, close all partners |
|
263 |
"/ |
|
264 |
type == #partner ifTrue:[ |
|
265 |
wg partnersDo:[:v | v ~~ self ifTrue:[v destroy]]. |
|
266 |
]. |
|
267 |
]. |
|
268 |
! |
|
269 |
||
270 |
mapped |
|
271 |
"the recevier was mapped (i.e. deiconified or just created); |
|
272 |
look for partners and slaves." |
|
273 |
||
274 |
realized := true. |
|
275 |
super mapped. |
|
276 |
windowGroup notNil ifTrue:[ |
|
277 |
(type == #master or:[type == #partner]) ifTrue:[ |
|
278 |
windowGroup slavesDo:[:v | v rerealize]. |
|
279 |
]. |
|
280 |
type == #partner ifTrue:[ |
|
281 |
windowGroup partnersDo:[:v | v ~~ self ifTrue:[v rerealize]]. |
|
282 |
] |
|
283 |
]. |
|
284 |
! |
|
285 |
||
286 |
unmapped |
|
287 |
"the recevier was unmapped (i.e. iconified); |
|
288 |
look for partners and slaves." |
|
289 |
||
290 |
super unmapped. |
|
291 |
windowGroup notNil ifTrue:[ |
|
292 |
(type == #master or:[type == #partner]) ifTrue:[ |
|
293 |
windowGroup slavesDo:[:v | v unrealize]. |
|
294 |
]. |
|
295 |
type == #partner ifTrue:[ |
|
296 |
windowGroup partnersDo:[:v | v ~~ self ifTrue:[v unrealize]]. |
|
297 |
]. |
|
298 |
]. |
|
299 |
||
300 |
! ! |
|
301 |
||
269 | 302 |
!TopView class methodsFor:'documentation'! |
135 | 303 |
|
269 | 304 |
version |
328 | 305 |
^ '$Header: /cvs/stx/stx/libview/TopView.st,v 1.11 1995-12-16 17:43:38 cg Exp $' |
135 | 306 |
! ! |