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 |
|
118
|
13 |
'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:02:34 am'!
|
|
14 |
|
0
|
15 |
PseudoView subclass:#View
|
118
|
16 |
instanceVariableNames:'superView subViews components style resources viewport
|
|
17 |
borderColor borderWidth borderShape viewShape top left
|
|
18 |
extentChanged originChanged cornerChanged relativeOrigin
|
|
19 |
relativeExtent relativeCorner originRule extentRule cornerRule
|
|
20 |
insets shown hidden name level margin innerClipRect shadowColor
|
129
|
21 |
lightColor bitGravity viewGravity
|
118
|
22 |
model controller windowGroup aspectSymbol changeSymbol menuSymbol'
|
|
23 |
classVariableNames:'Grey CentPoint ViewSpacing DefaultStyle StyleSheet
|
|
24 |
DefaultViewBackgroundColor DefaultBorderColor DefaultLightColor
|
|
25 |
DefaultShadowColor DefaultBorderWidth DefaultFont
|
|
26 |
DefaultFocusColor DefaultFocusBorderWidth'
|
|
27 |
poolDictionaries:''
|
|
28 |
category:'Views-Basic'
|
0
|
29 |
!
|
|
30 |
|
2
|
31 |
View class instanceVariableNames:'ClassResources'!
|
|
32 |
|
0
|
33 |
View comment:'
|
6
|
34 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
72
|
35 |
All Rights Reserved
|
|
36 |
|
133
|
37 |
$Header: /cvs/stx/stx/libview/View.st,v 1.40 1995-04-11 15:55:30 claus Exp $
|
2
|
38 |
'!
|
|
39 |
|
|
40 |
!View class methodsFor:'documentation'!
|
41
|
41 |
|
46
|
42 |
copyright
|
|
43 |
"
|
|
44 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
72
|
45 |
All Rights Reserved
|
46
|
46 |
|
|
47 |
This software is furnished under a license and may be used
|
|
48 |
only in accordance with the terms of that license and with the
|
|
49 |
inclusion of the above copyright notice. This software may not
|
|
50 |
be provided or otherwise made available to, or used by, any
|
|
51 |
other person. No title to or ownership of the software is
|
|
52 |
hereby transferred.
|
|
53 |
"
|
|
54 |
!
|
|
55 |
|
|
56 |
version
|
|
57 |
"
|
133
|
58 |
$Header: /cvs/stx/stx/libview/View.st,v 1.40 1995-04-11 15:55:30 claus Exp $
|
46
|
59 |
"
|
|
60 |
!
|
|
61 |
|
41
|
62 |
documentation
|
2
|
63 |
"
|
41
|
64 |
this class implements functions common to all Views.
|
82
|
65 |
Instances of View are seldom used, most views in the system inherit
|
|
66 |
from this class.
|
|
67 |
However, sometimes a view is used to create a dummy view for framing
|
|
68 |
or layout purposes.
|
41
|
69 |
|
|
70 |
Instance variables:
|
|
71 |
|
81
|
72 |
superView <View> my superview i.e. the view I am in
|
|
73 |
subViews <Collection> the collection of subviews
|
|
74 |
window <Rectangle> my window i.e. local coordinate-system
|
|
75 |
viewport <Rectangle> my Rectangle in superviews coordinates
|
|
76 |
borderColor <Color> color of border
|
|
77 |
borderWidth <Number> borderWidth in pixels (device dep.)
|
|
78 |
borderShape <Form> shape of border (if device supports it)
|
|
79 |
viewShape <Form> shape of view (if device supports it)
|
|
80 |
top <Number> top coordinate in superview
|
|
81 |
left <Number> left coordinate in superview
|
|
82 |
extendChanged <Boolean> true if extend changed during setup
|
|
83 |
originChanged <Boolean> true if origin changed during setup
|
|
84 |
relativeOrigin <Number> relative origin in percent within superview
|
|
85 |
relativeExtent <Number> relative extent in percent within superview
|
|
86 |
originRule <Block> rule to compute origin if superview changes size
|
|
87 |
extentRule <Block> rule to compute extent if superview changes size
|
98
|
88 |
shown <Boolean> true if visible (false if iconified, unmapped or covered)
|
81
|
89 |
hidden <Boolean> dont show automatically when superview is realized
|
|
90 |
name <String> my name (future use for resources)
|
|
91 |
level <Number> 3D level relative to superview
|
|
92 |
margin <Number> convenient margin
|
|
93 |
innerClipRect <Rectangle> convenient inner clip (minus margin)
|
|
94 |
shadowColor <Color> color used to draw 3D shadowed edges
|
|
95 |
lightColor <Color> color used to draw 3D lighted edges
|
|
96 |
contentsChanngeAction <Block> action to perform when model contents changes
|
|
97 |
originChangeAction <Block> action to perform when model origin changes
|
|
98 |
bitGravity <nil | Symbol> gravity of contents (if device supports it)
|
|
99 |
viewGravity <nil | Symbol> gravity of view (if device supports it)
|
|
100 |
model <nil | any> the model (if any)
|
|
101 |
controller <nil | Controller> the controller (if any)
|
|
102 |
|
41
|
103 |
|
|
104 |
Class variables:
|
|
105 |
|
81
|
106 |
Grey <Color> the color grey - its used so often
|
|
107 |
ViewSpacing <Number> prefered spacing between views; 1mm
|
|
108 |
|
|
109 |
CentPoint <Point> 100 @ 100 - its used so often
|
|
110 |
|
|
111 |
StyleSheet <ResourcePack> contains all view-style specifics
|
|
112 |
|
|
113 |
|
|
114 |
styleSheet parameters:
|
|
115 |
|
|
116 |
popupShadow <Boolean> if true, popupViews show a shadow below
|
|
117 |
popupLevel <nil | Integer> 3D level
|
|
118 |
borderWidth <nil | Integer> borderWidth (ignored in 3D styles)
|
|
119 |
borderColor <nil | Color> borderColor (ignored in 3D styles)
|
|
120 |
viewBackground <nil | Color> views background
|
|
121 |
shadowColor <nil | Color> color for shadow edges (ignored in 2D styles)
|
|
122 |
lightColor <nil | Color> color for light edges (ignored in 2D styles)
|
|
123 |
font <nil | Font> font to use
|
108
|
124 |
|
|
125 |
|
|
126 |
TODO:
|
|
127 |
get rid of relativeOrigin, relativeCorner, originRule, extentRule,
|
|
128 |
and insets; replace by a single object which defines the size
|
|
129 |
(mhmh - ST-80 seems to call this LayoutFrame ?)
|
123
|
130 |
-> be prepared for a change here in the near future and ONLY use
|
|
131 |
access methods to those instance variables
|
108
|
132 |
|
|
133 |
add components (could also call them gadgets or lightweight views)
|
|
134 |
- views are expensive in terms of X resources. This would make all
|
|
135 |
framing/edge and panel helper views become cheap ST objects, instead
|
|
136 |
of views.
|
2
|
137 |
"
|
|
138 |
! !
|
0
|
139 |
|
|
140 |
!View class methodsFor:'initialization'!
|
|
141 |
|
|
142 |
initialize
|
125
|
143 |
DefaultStyle isNil ifTrue:[
|
|
144 |
super initialize.
|
|
145 |
|
|
146 |
Font initialize.
|
|
147 |
Form initialize.
|
|
148 |
Color initialize.
|
|
149 |
|
133
|
150 |
Display notNil ifTrue:[
|
|
151 |
self defaultStyle:#normal.
|
|
152 |
].
|
125
|
153 |
|
123
|
154 |
"/ self updateStyleCache.
|
125
|
155 |
self == View ifTrue:[
|
|
156 |
Smalltalk addDependent:self "/ to get language changes
|
|
157 |
]
|
|
158 |
]
|
123
|
159 |
! !
|
|
160 |
|
|
161 |
!View class methodsFor:'change & update'!
|
|
162 |
|
|
163 |
update:something
|
|
164 |
something == #Language ifTrue:[
|
|
165 |
"flush resources on language changes"
|
|
166 |
self flushAllClassResources
|
|
167 |
]
|
0
|
168 |
! !
|
|
169 |
|
118
|
170 |
!View class methodsFor:'instance creation'!
|
|
171 |
|
|
172 |
in:aView
|
|
173 |
"return a new view as a subview of aView.
|
|
174 |
If aView is nil, it is left unspecified, in which superview
|
|
175 |
the new view will be placed. The view can later be assigned
|
|
176 |
by adding it to the superview via #addSubView:.
|
|
177 |
If realized and no superview has ever been set, it will come
|
|
178 |
up as a topview."
|
|
179 |
|
|
180 |
|newView|
|
|
181 |
|
|
182 |
newView := self basicNew.
|
|
183 |
aView notNil ifTrue:[
|
|
184 |
newView device:(aView device).
|
|
185 |
newView superView:aView.
|
|
186 |
] ifFalse:[
|
|
187 |
newView device:Display
|
|
188 |
].
|
|
189 |
newView initialize.
|
|
190 |
aView notNil ifTrue:[aView addSubView:newView].
|
|
191 |
^ newView
|
|
192 |
!
|
|
193 |
|
|
194 |
label:label in:aView
|
|
195 |
"create a new view as subview of aView with given label"
|
|
196 |
|
|
197 |
^ self origin:nil extent:nil borderWidth:nil
|
|
198 |
font:nil label:label in:aView
|
|
199 |
!
|
|
200 |
|
|
201 |
extent:extent in:aView
|
|
202 |
"create a new view as a subview of aView with given extent"
|
|
203 |
|
|
204 |
^ self origin:nil extent:extent borderWidth:nil
|
|
205 |
font:nil label:nil in:aView
|
|
206 |
!
|
|
207 |
|
|
208 |
origin:origin in:aView
|
|
209 |
"create a new view as a subview of aView with given origin"
|
|
210 |
|
|
211 |
^ self origin:origin extent:nil borderWidth:nil
|
|
212 |
font:nil label:nil in:aView
|
|
213 |
!
|
|
214 |
|
|
215 |
extent:extent
|
|
216 |
"create a new view with given extent"
|
|
217 |
|
|
218 |
^ self origin:nil extent:extent borderWidth:nil
|
|
219 |
font:nil label:nil in:nil
|
|
220 |
!
|
|
221 |
|
|
222 |
origin:origin extent:extent in:aView
|
|
223 |
"create a new view as a subview of aView with given origin and extent"
|
|
224 |
|
|
225 |
^ self origin:origin extent:extent borderWidth:nil
|
|
226 |
font:nil label:nil in:aView
|
|
227 |
!
|
|
228 |
|
|
229 |
origin:origin extent:extent
|
|
230 |
"create a new view with given origin and extent"
|
|
231 |
|
|
232 |
^ self origin:origin extent:extent borderWidth:nil
|
|
233 |
font:nil label:nil in:nil
|
|
234 |
!
|
|
235 |
|
|
236 |
origin:origin extent:extent borderWidth:bw in:aView
|
|
237 |
"create a new view as a subview of aView with given origin, extent
|
|
238 |
and borderWidth"
|
|
239 |
|
|
240 |
^ self origin:origin extent:extent borderWidth:bw
|
|
241 |
font:nil label:nil in:aView
|
|
242 |
!
|
|
243 |
|
|
244 |
origin:anOrigin extent:anExtent borderWidth:bw font:aFont label:aLabel in:aView
|
|
245 |
|newView|
|
|
246 |
|
|
247 |
aView notNil ifTrue:[
|
|
248 |
newView := self basicNew.
|
|
249 |
newView device:(aView device).
|
|
250 |
aView addSubView:newView.
|
|
251 |
newView initialize
|
|
252 |
] ifFalse:[
|
|
253 |
newView := self on:Display
|
|
254 |
].
|
|
255 |
bw notNil ifTrue:[newView borderWidth:bw].
|
|
256 |
anExtent notNil ifTrue:[newView extent:anExtent].
|
|
257 |
anOrigin notNil ifTrue:[newView origin:anOrigin].
|
|
258 |
aFont notNil ifTrue:[newView font:aFont].
|
|
259 |
aLabel notNil ifTrue:[newView label:aLabel].
|
|
260 |
^ newView
|
|
261 |
!
|
|
262 |
|
|
263 |
origin:anOrigin corner:aCorner borderWidth:bw font:aFont label:aLabel in:aView
|
|
264 |
|newView|
|
|
265 |
|
|
266 |
aView notNil ifTrue:[
|
|
267 |
newView := self basicNew.
|
|
268 |
newView device:(aView device).
|
|
269 |
aView addSubView:newView.
|
|
270 |
newView initialize
|
|
271 |
] ifFalse:[
|
|
272 |
newView := self on:Display
|
|
273 |
].
|
|
274 |
bw notNil ifTrue:[newView borderWidth:bw].
|
|
275 |
anOrigin notNil ifTrue:[newView origin:anOrigin].
|
|
276 |
aCorner notNil ifTrue:[newView corner:aCorner].
|
|
277 |
aFont notNil ifTrue:[newView font:aFont].
|
|
278 |
aLabel notNil ifTrue:[newView label:aLabel].
|
|
279 |
^ newView
|
|
280 |
!
|
|
281 |
|
|
282 |
origin:origin corner:corner in:aView
|
|
283 |
"create a new view as a subview of aView with given origin and extent"
|
|
284 |
|
|
285 |
^ self origin:origin corner:corner borderWidth:nil
|
|
286 |
font:nil label:nil in:aView
|
|
287 |
!
|
|
288 |
|
|
289 |
origin:origin extent:extent borderWidth:bw
|
|
290 |
"create a new view with given origin, extent and borderWidth"
|
|
291 |
|
|
292 |
^ self origin:origin extent:extent borderWidth:bw
|
|
293 |
font:nil label:nil in:nil
|
|
294 |
!
|
|
295 |
|
|
296 |
label:label
|
|
297 |
"create a new view with given label"
|
|
298 |
|
|
299 |
^ self origin:nil extent:nil borderWidth:nil
|
|
300 |
font:nil label:label in:nil
|
|
301 |
!
|
|
302 |
|
|
303 |
origin:anOrigin extent:anExtent
|
|
304 |
label:aLabel icon:aForm
|
|
305 |
minExtent:minExtent maxExtent:maxExtent
|
|
306 |
|newView|
|
|
307 |
|
|
308 |
newView := self on:Display.
|
|
309 |
anOrigin notNil ifTrue:[newView origin:anOrigin].
|
|
310 |
anExtent notNil ifTrue:[newView extent:anExtent].
|
|
311 |
aLabel notNil ifTrue:[newView label:aLabel].
|
|
312 |
aForm notNil ifTrue:[newView icon:aForm].
|
|
313 |
minExtent notNil ifTrue:[newView minExtent:minExtent].
|
|
314 |
maxExtent notNil ifTrue:[newView maxExtent:maxExtent].
|
|
315 |
^ newView
|
|
316 |
!
|
|
317 |
|
|
318 |
extent:extent label:label
|
|
319 |
"create a new view with given extent and label"
|
|
320 |
|
|
321 |
^ self origin:nil extent:extent borderWidth:nil
|
|
322 |
font:nil label:label in:nil
|
|
323 |
!
|
|
324 |
|
|
325 |
origin:origin extent:extent label:label
|
|
326 |
"create a new view with given origin, extent and label"
|
|
327 |
|
|
328 |
^ self origin:origin extent:extent borderWidth:nil
|
|
329 |
font:nil label:label in:nil
|
|
330 |
!
|
|
331 |
|
|
332 |
origin:origin extent:extent font:aFont label:label
|
|
333 |
^ self origin:origin extent:extent borderWidth:nil
|
|
334 |
font:nil label:label in:nil
|
|
335 |
!
|
|
336 |
|
|
337 |
origin:origin extent:extent font:aFont label:label in:aView
|
|
338 |
^ self origin:origin extent:extent borderWidth:nil
|
|
339 |
font:aFont label:label in:aView
|
|
340 |
!
|
|
341 |
|
|
342 |
origin:origin corner:corner borderWidth:bw in:aView
|
|
343 |
"create a new view as a subview of aView with given origin and extent"
|
|
344 |
|
|
345 |
^ self origin:origin corner:corner borderWidth:bw
|
|
346 |
font:nil label:nil in:aView
|
|
347 |
!
|
|
348 |
|
|
349 |
origin:origin corner:corner
|
|
350 |
"create a new view with given origin and extent"
|
|
351 |
|
|
352 |
^ self origin:origin corner:corner borderWidth:nil
|
|
353 |
font:nil label:nil in:nil
|
|
354 |
!
|
|
355 |
|
|
356 |
on:anObject aspect:aspectMsg change:changeMsg menu:menuMsg
|
|
357 |
"st-80 style view creation: create a new view, set its model
|
|
358 |
and access selectors for aspect, change and menu"
|
|
359 |
|
|
360 |
^ self new on:anObject
|
|
361 |
aspect:aspectMsg
|
|
362 |
change:changeMsg
|
|
363 |
menu:menuMsg
|
|
364 |
!
|
|
365 |
|
|
366 |
model:aModel
|
|
367 |
"st-80 style view creation: create a new view and set its model"
|
|
368 |
|
|
369 |
^ self new model:aModel
|
|
370 |
! !
|
|
371 |
|
123
|
372 |
!View class methodsFor:'resources'!
|
0
|
373 |
|
118
|
374 |
classResources
|
|
375 |
"if not already loaded, get the classes resourcePack
|
|
376 |
and return it"
|
|
377 |
|
|
378 |
ClassResources isNil ifTrue:[
|
|
379 |
ClassResources := ResourcePack for:self.
|
|
380 |
].
|
|
381 |
^ ClassResources
|
|
382 |
!
|
|
383 |
|
|
384 |
classResources:aResourcePack
|
|
385 |
"allow setting of the classResources"
|
|
386 |
|
|
387 |
ClassResources := aResourcePack
|
|
388 |
!
|
|
389 |
|
72
|
390 |
flushAllClassResources
|
|
391 |
"flush all classes resource translations.
|
|
392 |
Needed after a resource file has changed."
|
|
393 |
|
|
394 |
ResourcePack flushCachedResourcePacks.
|
|
395 |
self flushClassResources.
|
|
396 |
self allSubclassesDo:[:aClass |
|
123
|
397 |
aClass flushClassResources.
|
23
|
398 |
]
|
|
399 |
|
54
|
400 |
"
|
72
|
401 |
View flushAllClassResources
|
54
|
402 |
"
|
72
|
403 |
"to change the language:
|
|
404 |
Language := #english.
|
|
405 |
Smalltalk changed:#Language.
|
|
406 |
View flushAllClassResources
|
|
407 |
or:
|
|
408 |
Language := #german.
|
|
409 |
Smalltalk changed:#Language.
|
|
410 |
View flushAllClassResources
|
|
411 |
"
|
23
|
412 |
!
|
|
413 |
|
123
|
414 |
flushClassResources
|
|
415 |
"flush classes resource string translations.
|
|
416 |
Needed whenever a resource file or language has changed"
|
|
417 |
|
|
418 |
ClassResources := nil.
|
|
419 |
!
|
|
420 |
|
|
421 |
updateClassResources
|
|
422 |
"flush classes resource string translations and reload them.
|
|
423 |
Needed whenever a resource file or language has changed"
|
|
424 |
|
|
425 |
ClassResources := nil.
|
|
426 |
self classResources
|
|
427 |
! !
|
|
428 |
|
|
429 |
!View class methodsFor:'defaults'!
|
|
430 |
|
|
431 |
viewSpacing
|
|
432 |
"return a convenient number of pixels used to separate views (usually 1mm).
|
|
433 |
Having this value here at a common place makes certain that all views
|
|
434 |
get a common look"
|
|
435 |
|
|
436 |
^ ViewSpacing
|
|
437 |
!
|
|
438 |
|
|
439 |
defaultExtent
|
|
440 |
"define the default extent"
|
|
441 |
|
|
442 |
CentPoint isNil ifTrue:[CentPoint := 100 @ 100].
|
|
443 |
^ CentPoint
|
|
444 |
!
|
|
445 |
|
|
446 |
defaultStyle
|
|
447 |
"return the default view style"
|
|
448 |
|
|
449 |
^ DefaultStyle
|
|
450 |
|
|
451 |
"
|
|
452 |
View defaultStyle
|
|
453 |
"
|
|
454 |
!
|
|
455 |
|
72
|
456 |
defaultStyle:aStyle
|
|
457 |
"set the view style for new views"
|
|
458 |
|
|
459 |
aStyle ~~ DefaultStyle ifTrue:[
|
|
460 |
DefaultStyle := aStyle.
|
|
461 |
self updateAllStyleCaches.
|
|
462 |
]
|
|
463 |
|
|
464 |
"
|
|
465 |
View defaultStyle:#next. SystemBrowser start
|
|
466 |
View defaultStyle:#motif. SystemBrowser start
|
|
467 |
View defaultStyle:#iris. SystemBrowser start
|
|
468 |
View defaultStyle:#st80. SystemBrowser start
|
|
469 |
View defaultStyle:#normal. SystemBrowser start
|
|
470 |
"
|
|
471 |
!
|
|
472 |
|
|
473 |
updateAllStyleCaches
|
|
474 |
"reload all style caches in all view classes.
|
|
475 |
Needed after a style change or when a style file has been changed"
|
|
476 |
|
|
477 |
StyleSheet := ViewStyle fromFile:(DefaultStyle , '.style').
|
|
478 |
StyleSheet fileReadFailed ifTrue:[
|
|
479 |
('***** WARNING: no styleSheet for ' , DefaultStyle , '-style.') errorPrintNL.
|
|
480 |
DefaultStyle := #normal.
|
|
481 |
StyleSheet := ViewStyle fromFile:(DefaultStyle , '.style').
|
|
482 |
StyleSheet fileReadFailed ifTrue:[
|
|
483 |
'***** FATAL: not even a styleSheet for normal-style.' errorPrintNL.
|
118
|
484 |
Smalltalk exit
|
72
|
485 |
]
|
|
486 |
].
|
|
487 |
|
|
488 |
"
|
|
489 |
tell all view classes to flush any
|
|
490 |
cached style-data
|
|
491 |
"
|
|
492 |
self changed:#style.
|
|
493 |
self updateStyleCache.
|
|
494 |
self allSubclassesDo:[:aClass |
|
|
495 |
(aClass class implements:#updateStyleCache) ifTrue:[aClass updateStyleCache].
|
|
496 |
]
|
|
497 |
|
|
498 |
"
|
|
499 |
View updateAllStyleCaches
|
|
500 |
"
|
|
501 |
!
|
|
502 |
|
|
503 |
updateStyleCache
|
|
504 |
"this method gets some heavily used style stuff and keeps
|
|
505 |
it in class-variables for faster access.
|
|
506 |
Subclasses should redefine this to load any cached style-values
|
|
507 |
into faster class variables as well. These should NOT do a
|
|
508 |
super updateStyleCache, since this method is called for all view-classes
|
|
509 |
anyway."
|
|
510 |
|
|
511 |
|bgGrey|
|
|
512 |
|
|
513 |
"
|
|
514 |
when coming here the first time, we read the styleSheet
|
|
515 |
and keep the values in fast class variables
|
|
516 |
"
|
|
517 |
StyleSheet isNil ifTrue:[
|
|
518 |
DefaultStyle := #normal.
|
|
519 |
StyleSheet := ViewStyle fromFile:'normal.style'.
|
|
520 |
].
|
|
521 |
|
|
522 |
Grey := StyleSheet viewGrey.
|
|
523 |
Grey isNil ifTrue:[
|
|
524 |
Grey := Color grey
|
|
525 |
].
|
|
526 |
Grey := Grey on:Display.
|
81
|
527 |
|
72
|
528 |
Display hasGreyscales ifTrue:[
|
|
529 |
bgGrey := Grey
|
|
530 |
] ifFalse:[
|
|
531 |
bgGrey := White on:Display
|
|
532 |
].
|
|
533 |
|
|
534 |
ViewSpacing := StyleSheet at:'viewSpacing'.
|
|
535 |
ViewSpacing isNil ifTrue:[
|
|
536 |
ViewSpacing := Display verticalPixelPerMillimeter rounded.
|
|
537 |
].
|
|
538 |
|
|
539 |
DefaultBorderWidth := StyleSheet at:'borderWidth' default:0.
|
78
|
540 |
DefaultBorderColor := StyleSheet colorAt:'borderColor' default:Black.
|
|
541 |
DefaultViewBackgroundColor := StyleSheet colorAt:'viewBackground' default:bgGrey.
|
|
542 |
DefaultShadowColor := StyleSheet colorAt:'shadowColor'.
|
|
543 |
DefaultLightColor := StyleSheet colorAt:'lightColor'.
|
89
|
544 |
DefaultFocusColor := StyleSheet colorAt:'focusColor' default:Color red.
|
|
545 |
DefaultFocusBorderWidth := StyleSheet at:'focusBorderWidth' default:2.
|
|
546 |
|
72
|
547 |
DefaultFont := StyleSheet at:'font'.
|
|
548 |
DefaultFont isNil ifTrue:[
|
|
549 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12.
|
|
550 |
].
|
|
551 |
|
|
552 |
DefaultFont := DefaultFont on:Display.
|
81
|
553 |
|
|
554 |
DefaultViewBackgroundColor isNil ifTrue:[
|
|
555 |
'bad viewBackground in style - using white' errorPrintNL.
|
|
556 |
DefaultViewBackgroundColor := White
|
|
557 |
].
|
118
|
558 |
!
|
|
559 |
|
|
560 |
styleSheet:aViewStyle
|
|
561 |
"set the view style from a style-sheet"
|
|
562 |
|
|
563 |
StyleSheet := aViewStyle.
|
|
564 |
DefaultStyle := (StyleSheet at:'name' ifAbsent:'unknown') asSymbol.
|
|
565 |
self updateAllStyleCaches.
|
0
|
566 |
! !
|
|
567 |
|
118
|
568 |
!View methodsFor:'accessing-dimensions'!
|
0
|
569 |
|
|
570 |
extent:extent
|
118
|
571 |
"set the views extent; extent may be:
|
|
572 |
a point where integer fields mean pixel-values
|
|
573 |
and float values mean relative-to-superview;
|
|
574 |
or a block returning a point"
|
|
575 |
|
|
576 |
|w h pixelExtent e|
|
|
577 |
|
|
578 |
extent isBlock ifTrue:[
|
|
579 |
extentRule := extent.
|
|
580 |
drawableId notNil ifTrue:[
|
|
581 |
pixelExtent := extent value
|
|
582 |
] ifFalse:[
|
|
583 |
extentChanged := true
|
|
584 |
]
|
|
585 |
] ifFalse:[
|
|
586 |
w := extent x.
|
|
587 |
h := extent y.
|
|
588 |
w isNil ifTrue:[w := width].
|
|
589 |
h isNil ifTrue:[h := height].
|
|
590 |
e := w@h.
|
|
591 |
((w isInteger not) or:[h isInteger not]) ifTrue:[
|
|
592 |
relativeExtent := e.
|
|
593 |
pixelExtent := self extentFromRelativeExtent.
|
|
594 |
pixelExtent isNil ifTrue:[
|
|
595 |
extentChanged := true
|
|
596 |
]
|
|
597 |
] ifFalse:[
|
|
598 |
pixelExtent := e
|
|
599 |
]
|
|
600 |
].
|
|
601 |
pixelExtent notNil ifTrue:[
|
|
602 |
self pixelExtent:pixelExtent
|
|
603 |
]
|
|
604 |
!
|
|
605 |
|
|
606 |
top
|
|
607 |
"return the y position of the top border"
|
|
608 |
|
|
609 |
^ top
|
|
610 |
!
|
|
611 |
|
|
612 |
corner:corner
|
|
613 |
"set the views corner; corner may be:
|
|
614 |
a point where integer fields mean pixel-values
|
|
615 |
and float values mean relative-to-superview;
|
|
616 |
or a block returning a point"
|
|
617 |
|
|
618 |
|x y pixelCorner c|
|
|
619 |
|
|
620 |
corner isBlock ifTrue:[
|
|
621 |
cornerRule := corner.
|
|
622 |
drawableId notNil ifTrue:[
|
|
623 |
pixelCorner := corner value
|
|
624 |
] ifFalse:[
|
|
625 |
extentChanged := true
|
|
626 |
]
|
|
627 |
] ifFalse:[
|
|
628 |
x := corner x.
|
|
629 |
y := corner y.
|
|
630 |
x isNil ifTrue:[x := self corner x].
|
|
631 |
y isNil ifTrue:[y := self corner y].
|
|
632 |
c := x @ y.
|
|
633 |
((x isInteger not) or:[y isInteger not]) ifTrue:[
|
|
634 |
relativeCorner := c.
|
|
635 |
pixelCorner := self cornerFromRelativeCorner.
|
|
636 |
pixelCorner isNil ifTrue:[
|
|
637 |
extentChanged := true
|
|
638 |
]
|
|
639 |
] ifFalse:[
|
|
640 |
pixelCorner := c
|
|
641 |
]
|
|
642 |
].
|
|
643 |
|
|
644 |
pixelCorner notNil ifTrue:[
|
|
645 |
self pixelCorner:pixelCorner
|
|
646 |
]
|
0
|
647 |
!
|
|
648 |
|
|
649 |
origin:origin extent:extent
|
118
|
650 |
"set both origin and extent"
|
|
651 |
|
|
652 |
|newLeft newTop newWidth newHeight|
|
|
653 |
|
|
654 |
"do it as one operation if possible"
|
|
655 |
|
|
656 |
origin isBlock ifFalse:[
|
|
657 |
extent isBlock ifFalse:[
|
|
658 |
newLeft := origin x.
|
|
659 |
(newLeft isMemberOf:Float) ifFalse:[
|
|
660 |
newTop := origin y.
|
|
661 |
(newTop isMemberOf:Float) ifFalse:[
|
|
662 |
newWidth := extent x.
|
|
663 |
(newWidth isMemberOf:Float) ifFalse:[
|
|
664 |
newHeight := extent y.
|
|
665 |
(newHeight isMemberOf:Float) ifFalse:[
|
|
666 |
self pixelOrigin:origin extent:extent
|
|
667 |
]
|
|
668 |
]
|
|
669 |
]
|
|
670 |
]
|
|
671 |
]
|
|
672 |
].
|
|
673 |
self extent:extent.
|
|
674 |
self origin:origin
|
|
675 |
!
|
|
676 |
|
|
677 |
origin
|
|
678 |
"return the origin (in pixels)"
|
|
679 |
|
|
680 |
^ left@top
|
|
681 |
!
|
|
682 |
|
|
683 |
innerWidth
|
|
684 |
"return the width of the view minus any 3D-shadow-borders"
|
|
685 |
|
|
686 |
(level == 0) ifTrue:[^ width].
|
|
687 |
^ width - (2 * margin)
|
|
688 |
!
|
|
689 |
|
|
690 |
origin:origin
|
|
691 |
"set the views origin; origin may be:
|
|
692 |
a point where integer fields mean pixel-values
|
|
693 |
and float values mean relative-to-superview;
|
|
694 |
or a block returning a point"
|
|
695 |
|
|
696 |
|newLeft newTop pixelOrigin o|
|
|
697 |
|
|
698 |
origin isBlock ifTrue:[
|
|
699 |
originRule := origin.
|
|
700 |
drawableId notNil ifTrue:[
|
|
701 |
pixelOrigin := origin value
|
|
702 |
] ifFalse:[
|
|
703 |
originChanged := true
|
|
704 |
]
|
0
|
705 |
] ifFalse:[
|
118
|
706 |
o := origin.
|
|
707 |
newLeft := origin x.
|
|
708 |
newTop := origin y.
|
|
709 |
newLeft isNil ifTrue:[newLeft := left].
|
|
710 |
newTop isNil ifTrue:[newTop := top].
|
|
711 |
o := newLeft @ newTop.
|
|
712 |
((newLeft isInteger not) or:[newTop isInteger not]) ifTrue:[
|
|
713 |
relativeOrigin := o.
|
|
714 |
pixelOrigin := self originFromRelativeOrigin.
|
|
715 |
pixelOrigin isNil ifTrue:[
|
|
716 |
originChanged := true
|
|
717 |
]
|
|
718 |
] ifFalse:[
|
|
719 |
pixelOrigin := o
|
|
720 |
]
|
|
721 |
].
|
|
722 |
pixelOrigin notNil ifTrue:[
|
|
723 |
self pixelOrigin:pixelOrigin
|
0
|
724 |
].
|
118
|
725 |
!
|
|
726 |
|
|
727 |
height:aNumber
|
|
728 |
"set the views height in pixels"
|
|
729 |
|
|
730 |
self extent:(width @ aNumber)
|
|
731 |
!
|
|
732 |
|
133
|
733 |
sizeFixed:aBoolean
|
|
734 |
"set/clear the fix-size attribute, if supported by concrete subclasses.
|
|
735 |
Views which want to resize themselfes as appropriate to their contents
|
|
736 |
should cease to do so and take their current size if sizeFixed is set to
|
|
737 |
true. Currently, only supported by Labels.
|
|
738 |
Added here to provide a common protocol for all views"
|
|
739 |
|
|
740 |
^ self
|
|
741 |
!
|
|
742 |
|
118
|
743 |
makeFullyVisible
|
|
744 |
"make sure, that the view is fully visible by shifting it
|
133
|
745 |
into the visible screen area if nescessary.
|
|
746 |
This method will be moved to StandardSystemView ..."
|
118
|
747 |
|
|
748 |
((top + height) > (device height)) ifTrue:[
|
|
749 |
self top:(device height - height)
|
|
750 |
].
|
|
751 |
((left + width) > (device width)) ifTrue:[
|
|
752 |
self left:(device width - width)
|
|
753 |
].
|
|
754 |
(top < 0) ifTrue:[
|
|
755 |
self top:0
|
|
756 |
].
|
|
757 |
(left < 0) ifTrue:[
|
|
758 |
self left:0
|
|
759 |
].
|
0
|
760 |
!
|
|
761 |
|
|
762 |
origin:origin corner:corner
|
118
|
763 |
"set both origin and extent"
|
|
764 |
|
|
765 |
|newLeft newTop newRight newBot|
|
|
766 |
|
|
767 |
"do it as one operation if possible"
|
|
768 |
|
|
769 |
origin isBlock ifFalse:[
|
|
770 |
corner isBlock ifFalse:[
|
|
771 |
newLeft := origin x.
|
|
772 |
(newLeft isMemberOf:Float) ifFalse:[
|
|
773 |
newTop := origin y.
|
|
774 |
(newTop isMemberOf:Float) ifFalse:[
|
|
775 |
newRight := corner x.
|
|
776 |
(newRight isMemberOf:Float) ifFalse:[
|
|
777 |
newBot := corner y.
|
|
778 |
(newBot isMemberOf:Float) ifFalse:[
|
|
779 |
self pixelOrigin:origin corner:corner
|
|
780 |
]
|
|
781 |
]
|
|
782 |
]
|
|
783 |
]
|
72
|
784 |
]
|
46
|
785 |
].
|
118
|
786 |
self origin:origin.
|
|
787 |
self corner:corner
|
|
788 |
!
|
|
789 |
|
|
790 |
relativeCorner
|
|
791 |
"return the relative corner or nil"
|
|
792 |
|
|
793 |
^ relativeCorner
|
|
794 |
!
|
|
795 |
|
|
796 |
width:aNumber
|
|
797 |
"set the views width in pixels"
|
|
798 |
|
|
799 |
self extent:(aNumber @ height)
|
|
800 |
!
|
0
|
801 |
|
|
802 |
left:aNumber
|
|
803 |
"set the x position"
|
|
804 |
|
|
805 |
self origin:(aNumber @ top)
|
|
806 |
!
|
|
807 |
|
|
808 |
top:aNumber
|
|
809 |
"set the y position"
|
|
810 |
|
|
811 |
self origin:(left @ aNumber)
|
|
812 |
!
|
|
813 |
|
123
|
814 |
rightInset
|
|
815 |
"return the inset of the right edge; positive is to the left,
|
|
816 |
negative to the right"
|
|
817 |
|
|
818 |
insets isNil ifTrue:[^ 0].
|
|
819 |
^ insets at:3
|
|
820 |
!
|
|
821 |
|
118
|
822 |
rightInset:aNumber
|
|
823 |
"set the inset of the right edge; positive is to the left,
|
|
824 |
negative to the right"
|
|
825 |
|
|
826 |
insets isNil ifTrue:[
|
|
827 |
insets := Array new:4 withAll:0.
|
|
828 |
].
|
|
829 |
insets at:3 put:aNumber.
|
|
830 |
|
|
831 |
"force recomputation"
|
|
832 |
drawableId isNil ifTrue:[
|
|
833 |
originChanged := true
|
|
834 |
] ifFalse:[
|
|
835 |
self superViewChangedSize
|
|
836 |
]
|
0
|
837 |
!
|
|
838 |
|
123
|
839 |
leftInset
|
|
840 |
"return the inset of the left edge; positive is to the right,
|
|
841 |
negative to the left"
|
|
842 |
|
|
843 |
insets isNil ifTrue:[^ 0].
|
|
844 |
^ insets at:1
|
|
845 |
!
|
|
846 |
|
46
|
847 |
leftInset:aNumber
|
72
|
848 |
"set the inset of the left edge; positive is to the right,
|
|
849 |
negative to the left"
|
|
850 |
|
82
|
851 |
insets isNil ifTrue:[
|
|
852 |
insets := Array new:4 withAll:0.
|
|
853 |
].
|
|
854 |
insets at:1 put:aNumber.
|
|
855 |
|
46
|
856 |
"force recomputation"
|
|
857 |
drawableId isNil ifTrue:[
|
72
|
858 |
originChanged := true
|
46
|
859 |
] ifFalse:[
|
72
|
860 |
self superViewChangedSize
|
46
|
861 |
]
|
|
862 |
!
|
|
863 |
|
123
|
864 |
topInset
|
|
865 |
"return the inset of the top edge; positive is to the bottom,
|
|
866 |
negative to the top"
|
|
867 |
|
|
868 |
insets isNil ifTrue:[^ 0].
|
|
869 |
^ insets at:2
|
|
870 |
!
|
|
871 |
|
46
|
872 |
topInset:aNumber
|
72
|
873 |
"set the inset of the top edge; positive is to the bottom,
|
|
874 |
negative to the top"
|
|
875 |
|
82
|
876 |
insets isNil ifTrue:[
|
|
877 |
insets := Array new:4 withAll:0.
|
|
878 |
].
|
|
879 |
insets at:2 put:aNumber.
|
|
880 |
|
46
|
881 |
"force recomputation"
|
|
882 |
drawableId isNil ifTrue:[
|
72
|
883 |
originChanged := true
|
46
|
884 |
] ifFalse:[
|
72
|
885 |
self superViewChangedSize
|
46
|
886 |
]
|
|
887 |
!
|
|
888 |
|
123
|
889 |
bottomInset
|
|
890 |
"return the inset of the bottom edge; positive is to the top,
|
|
891 |
negative to the bottom"
|
|
892 |
|
|
893 |
insets isNil ifTrue:[^ 0].
|
|
894 |
^ insets at:4
|
|
895 |
!
|
|
896 |
|
46
|
897 |
bottomInset:aNumber
|
72
|
898 |
"set the inset of the bottom edge; positive is to the top,
|
|
899 |
negative to the bottom"
|
|
900 |
|
82
|
901 |
insets isNil ifTrue:[
|
|
902 |
insets := Array new:4 withAll:0.
|
|
903 |
].
|
|
904 |
insets at:4 put:aNumber.
|
|
905 |
|
46
|
906 |
"force recomputation"
|
|
907 |
drawableId isNil ifTrue:[
|
72
|
908 |
originChanged := true
|
46
|
909 |
] ifFalse:[
|
72
|
910 |
self superViewChangedSize
|
46
|
911 |
]
|
|
912 |
!
|
|
913 |
|
118
|
914 |
relativeOrigin
|
|
915 |
"return the relative origin or nil"
|
|
916 |
|
|
917 |
^ relativeOrigin
|
|
918 |
!
|
|
919 |
|
|
920 |
right:aNumber
|
|
921 |
"set the corners x position"
|
|
922 |
|
|
923 |
self corner:(aNumber @ self corner y)
|
|
924 |
!
|
|
925 |
|
|
926 |
bottom:aNumber
|
|
927 |
"set the corners y position"
|
|
928 |
|
|
929 |
self corner:(self corner x @ aNumber)
|
|
930 |
!
|
|
931 |
|
|
932 |
corner
|
|
933 |
"return the lower right corner-point"
|
|
934 |
|
|
935 |
^ (left + width - 1) @ (top + height - 1)
|
|
936 |
!
|
|
937 |
|
|
938 |
innerHeight
|
|
939 |
"return the height of the view minus any 3D-shadow-borders"
|
|
940 |
|
|
941 |
(margin == 0) ifTrue:[^ height].
|
|
942 |
^ height - (2 * margin)
|
|
943 |
!
|
|
944 |
|
|
945 |
relativeCorner:aPoint
|
|
946 |
"set the relative corner"
|
|
947 |
|
|
948 |
relativeCorner := aPoint
|
|
949 |
!
|
|
950 |
|
87
|
951 |
inset:aNumber
|
|
952 |
"set all insets; positive makes the view smaller,
|
|
953 |
negative makes it larger."
|
|
954 |
|
|
955 |
insets isNil ifTrue:[
|
|
956 |
insets := Array new:4.
|
|
957 |
].
|
|
958 |
insets atAllPut:aNumber.
|
|
959 |
|
|
960 |
"force recomputation"
|
|
961 |
drawableId isNil ifTrue:[
|
|
962 |
originChanged := true
|
|
963 |
] ifFalse:[
|
|
964 |
self superViewChangedSize
|
|
965 |
]
|
|
966 |
!
|
|
967 |
|
0
|
968 |
left:newLeft top:newTop width:newWidth height:newHeight
|
|
969 |
"another way of specifying origin and extent"
|
|
970 |
|
|
971 |
self origin:(newLeft @ newTop) extent:(newWidth @ newHeight)
|
|
972 |
!
|
|
973 |
|
|
974 |
relativeExtent
|
|
975 |
"return the relative extent or nil"
|
|
976 |
|
|
977 |
^ relativeExtent
|
|
978 |
!
|
|
979 |
|
|
980 |
relativeOrigin:aPoint
|
|
981 |
"set the relative origin"
|
|
982 |
|
|
983 |
relativeOrigin := aPoint
|
|
984 |
!
|
|
985 |
|
|
986 |
originRelativeTo:aView
|
123
|
987 |
"return the origin (in pixels) relative to a superView,
|
|
988 |
or relative to the Display (if aView is nil).
|
|
989 |
If the receiver is not a subview of aView, return nil."
|
0
|
990 |
|
|
991 |
|currentView
|
|
992 |
org "{ Class: Point }"
|
|
993 |
sumX "{ Class: SmallInteger }"
|
|
994 |
sumY "{ Class: SmallInteger }" |
|
|
995 |
|
|
996 |
currentView := self.
|
|
997 |
sumX := 0.
|
|
998 |
sumY := 0.
|
|
999 |
[currentView notNil] whileTrue:[
|
72
|
1000 |
(currentView == aView) ifTrue:[
|
|
1001 |
^ (sumX @ sumY)
|
|
1002 |
].
|
|
1003 |
org := currentView origin.
|
|
1004 |
sumX := sumX + org x.
|
|
1005 |
sumY := sumY + org y.
|
|
1006 |
currentView := currentView superView
|
0
|
1007 |
].
|
123
|
1008 |
(aView isNil or:[aView == RootView]) ifTrue:[
|
|
1009 |
"return relative to screen ..."
|
|
1010 |
^ (sumX @ sumY)
|
|
1011 |
].
|
0
|
1012 |
^ nil
|
|
1013 |
!
|
|
1014 |
|
118
|
1015 |
relativeExtent:aPoint
|
|
1016 |
"set the relative extent"
|
|
1017 |
|
|
1018 |
relativeExtent := aPoint
|
|
1019 |
!
|
|
1020 |
|
|
1021 |
center:newCenter
|
|
1022 |
"move the receiver so that newCenter, aPoint becomes the center point"
|
|
1023 |
|
|
1024 |
self origin:(newCenter - ((width // 2) @ (height // 2)))
|
|
1025 |
!
|
|
1026 |
|
|
1027 |
center
|
|
1028 |
"return the point at the center of the receiver"
|
|
1029 |
|
|
1030 |
^ (left + (width // 2)) @ (top + (height // 2))
|
|
1031 |
!
|
|
1032 |
|
0
|
1033 |
left
|
|
1034 |
"return the x position of the left border"
|
|
1035 |
|
|
1036 |
^ left
|
|
1037 |
!
|
|
1038 |
|
|
1039 |
right
|
|
1040 |
"return the x position of the right border"
|
|
1041 |
|
|
1042 |
^ left + width - 1
|
|
1043 |
!
|
|
1044 |
|
|
1045 |
bottom
|
|
1046 |
"return the y position of the bottom border"
|
|
1047 |
|
|
1048 |
^ top + height - 1
|
|
1049 |
!
|
|
1050 |
|
118
|
1051 |
computeCorner
|
|
1052 |
"compute my corner; if I have relative
|
121
|
1053 |
origins or blocks to evaluate, do it now ..
|
|
1054 |
Blocks may return relative values or nil; nil means: take current value."
|
|
1055 |
|
|
1056 |
|org newCorner newExt x y|
|
118
|
1057 |
|
|
1058 |
(cornerRule notNil) ifTrue:[
|
121
|
1059 |
newCorner := cornerRule value.
|
|
1060 |
"
|
|
1061 |
allow return of relative values ...
|
|
1062 |
"
|
|
1063 |
x := newCorner x.
|
|
1064 |
y := newCorner y.
|
|
1065 |
x isNil ifTrue:[x := self corner x].
|
|
1066 |
y isNil ifTrue:[y := self corner y].
|
|
1067 |
((x isInteger not) or:[y isInteger not]) ifTrue:[
|
|
1068 |
newCorner := self cornerFromRelativeCorner:x@y
|
|
1069 |
]
|
0
|
1070 |
] ifFalse:[
|
118
|
1071 |
(relativeCorner notNil) ifTrue:[
|
121
|
1072 |
newCorner := self cornerFromRelativeCorner:relativeCorner
|
118
|
1073 |
] ifFalse:[
|
|
1074 |
org := self computeOrigin.
|
|
1075 |
(extentRule notNil) ifTrue:[
|
|
1076 |
newExt := extentRule value
|
81
|
1077 |
] ifFalse:[
|
118
|
1078 |
(relativeExtent notNil) ifTrue:[
|
121
|
1079 |
newExt := self extentFromRelativeExtent:relativeExtent
|
118
|
1080 |
]
|
72
|
1081 |
].
|
118
|
1082 |
newCorner := org + newExt
|
87
|
1083 |
]
|
|
1084 |
].
|
118
|
1085 |
^ newCorner
|
|
1086 |
!
|
|
1087 |
|
|
1088 |
computeExtent
|
|
1089 |
"compute my extent; if I have relative
|
121
|
1090 |
extent or blocks to evaluate, do it now ..
|
|
1091 |
There is one catch here, if the dimension was defined
|
|
1092 |
by origin/corner, compute them here and take that value.
|
|
1093 |
I.e. origin/corner definition has precedence over extent definition."
|
|
1094 |
|
|
1095 |
|newOrg newExt newCorner x y|
|
118
|
1096 |
|
|
1097 |
(cornerRule notNil) ifTrue:[
|
121
|
1098 |
newCorner := cornerRule value.
|
|
1099 |
"
|
|
1100 |
allow return of relative values ...
|
|
1101 |
"
|
|
1102 |
x := newCorner x.
|
|
1103 |
y := newCorner y.
|
|
1104 |
x isNil ifTrue:[x := self corner x].
|
|
1105 |
y isNil ifTrue:[y := self corner y].
|
|
1106 |
((x isInteger not) or:[y isInteger not]) ifTrue:[
|
|
1107 |
newCorner := self cornerFromRelativeCorner:x@y
|
|
1108 |
]
|
118
|
1109 |
] ifFalse:[
|
|
1110 |
(relativeCorner notNil) ifTrue:[
|
121
|
1111 |
newCorner := self cornerFromRelativeCorner:relativeCorner
|
118
|
1112 |
] ifFalse:[
|
|
1113 |
(extentRule notNil) ifTrue:[
|
121
|
1114 |
newExt := extentRule value.
|
|
1115 |
"
|
|
1116 |
allow return of relative values ...
|
|
1117 |
"
|
|
1118 |
x := newExt x.
|
|
1119 |
y := newExt y.
|
|
1120 |
x isNil ifTrue:[x := width].
|
|
1121 |
y isNil ifTrue:[y := height].
|
|
1122 |
((x isInteger not) or:[y isInteger not]) ifTrue:[
|
|
1123 |
newExt := self extentFromRelativeExtent:x@y
|
|
1124 |
]
|
118
|
1125 |
] ifFalse:[
|
|
1126 |
(relativeExtent notNil) ifTrue:[
|
121
|
1127 |
newExt := self extentFromRelativeExtent:relativeExtent
|
118
|
1128 |
] ifFalse:[
|
|
1129 |
newExt := (width @ height).
|
|
1130 |
].
|
|
1131 |
].
|
|
1132 |
].
|
0
|
1133 |
].
|
118
|
1134 |
|
|
1135 |
newCorner notNil ifTrue:[
|
121
|
1136 |
newOrg := self computeOrigin.
|
118
|
1137 |
^ newCorner - newOrg.
|
|
1138 |
].
|
|
1139 |
^ newExt.
|
|
1140 |
!
|
|
1141 |
|
|
1142 |
computeOrigin
|
|
1143 |
"compute my origin; if I have relative
|
121
|
1144 |
origins or blocks to evaluate, do it now ..
|
|
1145 |
Blocks may return relative values or nil; nil means: take current value."
|
|
1146 |
|
|
1147 |
|newOrg x y|
|
118
|
1148 |
|
|
1149 |
(originRule notNil) ifTrue:[
|
|
1150 |
newOrg := originRule value.
|
121
|
1151 |
"
|
|
1152 |
allow return of relative values ...
|
|
1153 |
"
|
|
1154 |
x := newOrg x.
|
|
1155 |
y := newOrg y.
|
|
1156 |
x isNil ifTrue:[x := self origin x].
|
|
1157 |
y isNil ifTrue:[y := self origin y].
|
|
1158 |
((x isInteger not) or:[y isInteger not]) ifTrue:[
|
|
1159 |
newOrg := self originFromRelativeOrigin:x@y.
|
72
|
1160 |
]
|
118
|
1161 |
] ifFalse:[
|
|
1162 |
(relativeOrigin notNil) ifTrue:[
|
121
|
1163 |
newOrg := self originFromRelativeOrigin:relativeOrigin.
|
118
|
1164 |
] ifFalse:[
|
|
1165 |
^ (left @ top).
|
|
1166 |
].
|
0
|
1167 |
].
|
118
|
1168 |
^ newOrg
|
0
|
1169 |
! !
|
|
1170 |
|
|
1171 |
!View methodsFor:'informing others of changes'!
|
|
1172 |
|
118
|
1173 |
originChanged:delta
|
|
1174 |
"this one is sent, after the origin of my contents has changed -
|
|
1175 |
tell dependents (i.e. scrollers) about this"
|
|
1176 |
|
|
1177 |
self changed:#originOfContents with:delta.
|
|
1178 |
"/ subViews notNil ifTrue:[
|
|
1179 |
"/ subViews do:[:aSubView |
|
|
1180 |
"/ aSubView pixelOrigin:((aSubView left @ aSubView top) - delta)
|
|
1181 |
"/ ]
|
|
1182 |
"/ ]
|
|
1183 |
!
|
|
1184 |
|
|
1185 |
contentsChanged
|
|
1186 |
"this one is sent, whenever contents changes size -
|
|
1187 |
tell dependents about the change (i.e. scrollers)."
|
|
1188 |
|
|
1189 |
self changed:#sizeOfContents
|
|
1190 |
!
|
|
1191 |
|
0
|
1192 |
originWillChange
|
|
1193 |
"this one is sent, just before viewOrigin changes -
|
|
1194 |
gives subclasses a chance to catch scrolls easily
|
|
1195 |
(for example to hide cursor before scroll)"
|
|
1196 |
|
|
1197 |
^ self
|
|
1198 |
! !
|
|
1199 |
|
118
|
1200 |
!View methodsFor:'accessing-mvc'!
|
|
1201 |
|
|
1202 |
sendChangeMessageWith:arg
|
|
1203 |
|n|
|
|
1204 |
|
|
1205 |
"/
|
|
1206 |
"/ MVC way of doing it
|
|
1207 |
"/
|
|
1208 |
(model notNil and:[changeSymbol notNil]) ifTrue:[
|
|
1209 |
n := changeSymbol numArgs.
|
|
1210 |
n == 0 ifTrue:[
|
|
1211 |
model perform:changeSymbol
|
107
|
1212 |
] ifFalse:[
|
118
|
1213 |
n == 1 ifTrue:[
|
|
1214 |
model perform:changeSymbol with:arg
|
|
1215 |
] ifFalse:[
|
|
1216 |
model perform:changeSymbol with:arg with:self
|
|
1217 |
]
|
72
|
1218 |
]
|
0
|
1219 |
]
|
|
1220 |
!
|
|
1221 |
|
118
|
1222 |
windowGroup
|
|
1223 |
"return the window group. For old style views, return nil"
|
|
1224 |
|
|
1225 |
^ windowGroup
|
|
1226 |
!
|
|
1227 |
|
|
1228 |
windowGroup:aGroup
|
|
1229 |
"set the window group."
|
|
1230 |
|
|
1231 |
windowGroup := aGroup
|
|
1232 |
!
|
|
1233 |
|
|
1234 |
model
|
|
1235 |
"return the model, for non-MVC views,
|
|
1236 |
this is nil or the receiver"
|
|
1237 |
|
|
1238 |
^ model
|
|
1239 |
!
|
|
1240 |
|
|
1241 |
model:aModel
|
|
1242 |
"set the model"
|
|
1243 |
|
|
1244 |
model notNil ifTrue:[
|
|
1245 |
model removeDependent:self
|
89
|
1246 |
].
|
118
|
1247 |
model := aModel.
|
|
1248 |
model notNil ifTrue:[
|
|
1249 |
aModel addDependent:self
|
|
1250 |
].
|
|
1251 |
controller notNil ifTrue:[
|
|
1252 |
controller model:aModel
|
|
1253 |
]
|
|
1254 |
!
|
|
1255 |
|
|
1256 |
controller
|
|
1257 |
"return the controller. For non MVC views, return nil"
|
|
1258 |
|
|
1259 |
^ controller
|
|
1260 |
!
|
|
1261 |
|
|
1262 |
controller:aController
|
|
1263 |
"set the controller"
|
|
1264 |
|
|
1265 |
controller := aController.
|
|
1266 |
controller notNil ifTrue:[
|
|
1267 |
controller view:self.
|
|
1268 |
controller model:model
|
0
|
1269 |
]
|
|
1270 |
!
|
|
1271 |
|
118
|
1272 |
on:aModel aspect:aspectMsg
|
|
1273 |
"ST-80 compatibility: set model and aspect
|
|
1274 |
messages - needs a view which uses these"
|
|
1275 |
|
|
1276 |
aspectSymbol := aspectMsg.
|
|
1277 |
self model:aModel.
|
|
1278 |
!
|
|
1279 |
|
|
1280 |
on:aModel aspect:aspectMsg menu:menuMsg
|
|
1281 |
"ST-80 compatibility: set model, aspect and menu
|
|
1282 |
messages - needs a view which uses these"
|
|
1283 |
|
|
1284 |
aspectSymbol := aspectMsg.
|
|
1285 |
menuSymbol := menuMsg.
|
|
1286 |
self model:aModel.
|
|
1287 |
!
|
|
1288 |
|
|
1289 |
on:aModel aspect:aspectMsg change:changeMsg menu:menuMsg
|
|
1290 |
"ST-80 compatibility: set model, aspect, change and menu
|
|
1291 |
messages - needs a view which uses these"
|
|
1292 |
|
|
1293 |
aspectSymbol := aspectMsg.
|
|
1294 |
changeSymbol := changeMsg.
|
|
1295 |
menuSymbol := menuMsg.
|
|
1296 |
self model:aModel.
|
|
1297 |
!
|
|
1298 |
|
|
1299 |
menu:menuMsg
|
|
1300 |
"ST-80 style menus: If a views menuSymbol is nonNil, it
|
|
1301 |
will send it to its model when the middleButton is pressed.
|
|
1302 |
That method should return nil or the menu to be shown.
|
|
1303 |
This is useful for very dynamic menus, where it does not
|
|
1304 |
make sense to define an initial menu."
|
|
1305 |
|
|
1306 |
menuSymbol := menuMsg
|
|
1307 |
!
|
|
1308 |
|
|
1309 |
change:changeMsg
|
|
1310 |
"ST-80 style change notification: If a views changeSymbol is nonNil,
|
|
1311 |
it will send it to its model when something changes."
|
|
1312 |
|
|
1313 |
changeSymbol := changeMsg
|
|
1314 |
!
|
|
1315 |
|
|
1316 |
aspect:aspectMsg
|
|
1317 |
"ST-80 style updating: If a views aspectSymbol is nonNil,
|
|
1318 |
it will respond to changes of this aspect from the model."
|
|
1319 |
|
|
1320 |
aspectSymbol := aspectMsg
|
|
1321 |
!
|
|
1322 |
|
|
1323 |
changeSymbol
|
|
1324 |
"Return the symbol sent to the model if nonNil when something changes."
|
|
1325 |
|
|
1326 |
^ changeSymbol
|
|
1327 |
!
|
|
1328 |
|
|
1329 |
menuSymbol
|
|
1330 |
"Return the symbol sent to the model to aquire the menu"
|
|
1331 |
|
|
1332 |
^ menuSymbol
|
|
1333 |
!
|
|
1334 |
|
|
1335 |
aspectSymbol
|
|
1336 |
"Return the aspect used with changes from/to the model"
|
|
1337 |
|
|
1338 |
^ menuSymbol
|
0
|
1339 |
! !
|
|
1340 |
|
|
1341 |
!View methodsFor:'private'!
|
|
1342 |
|
|
1343 |
pixelExtent:extent
|
|
1344 |
"set the views extent in pixels"
|
|
1345 |
|
15
|
1346 |
self pixelOrigin:(left @ top) extent:extent
|
|
1347 |
!
|
|
1348 |
|
0
|
1349 |
pixelOrigin:origin
|
81
|
1350 |
"set the views origin in pixels. For subviews. the origin is relative
|
|
1351 |
to the superviews top-left. For topViews, its the screen origin."
|
0
|
1352 |
|
|
1353 |
|newLeft newTop|
|
|
1354 |
|
|
1355 |
newLeft := origin x.
|
|
1356 |
newTop := origin y.
|
|
1357 |
((newTop ~~ top) or:[newLeft ~~ left]) ifTrue:[
|
72
|
1358 |
top := newTop.
|
|
1359 |
left := newLeft.
|
81
|
1360 |
|
|
1361 |
"
|
|
1362 |
if the receiver is visible, or is a topView, perform the
|
|
1363 |
operation right away - otherwise, simply remember that the
|
|
1364 |
origin has changed - will tell the display once we get realized
|
|
1365 |
"
|
|
1366 |
(shown
|
|
1367 |
or:[superView isNil and:[drawableId notNil]]) ifTrue:[
|
72
|
1368 |
device moveWindow:drawableId x:left y:top
|
81
|
1369 |
] ifFalse:[
|
72
|
1370 |
originChanged := true
|
|
1371 |
]
|
0
|
1372 |
]
|
|
1373 |
!
|
|
1374 |
|
118
|
1375 |
computeInnerClip
|
|
1376 |
"compute, but do not set the inside clip-area"
|
|
1377 |
|
|
1378 |
|m2 nX nY nW nH|
|
|
1379 |
|
|
1380 |
(margin ~~ 0) ifTrue:[
|
|
1381 |
m2 := margin + margin.
|
|
1382 |
nX := nY := margin.
|
|
1383 |
nW := width - m2.
|
|
1384 |
nH := height - m2.
|
|
1385 |
transformation notNil ifTrue:[
|
|
1386 |
nX := transformation applyInverseToX:nX.
|
|
1387 |
nY := transformation applyInverseToY:nY.
|
|
1388 |
nW := transformation applyInverseScaleX:nW.
|
|
1389 |
nH := transformation applyInverseScaleY:nH.
|
|
1390 |
].
|
|
1391 |
innerClipRect := Rectangle
|
|
1392 |
left:nX
|
|
1393 |
top:nY
|
|
1394 |
width:nW
|
|
1395 |
height:nH
|
|
1396 |
] ifFalse:[
|
|
1397 |
"no clipping"
|
|
1398 |
innerClipRect := nil
|
|
1399 |
]
|
|
1400 |
!
|
|
1401 |
|
|
1402 |
setInnerClip
|
|
1403 |
"compute, and set the inside clip-area"
|
|
1404 |
|
|
1405 |
self computeInnerClip.
|
|
1406 |
self clipRect:innerClipRect
|
|
1407 |
!
|
|
1408 |
|
|
1409 |
originFromRelativeOrigin
|
|
1410 |
"compute & return pixel origin from relativeOrigin"
|
|
1411 |
|
|
1412 |
^ self originFromRelativeOrigin:relativeOrigin
|
0
|
1413 |
!
|
|
1414 |
|
|
1415 |
pixelOrigin:origin extent:extent
|
|
1416 |
"set the views origin and extent in pixels"
|
|
1417 |
|
15
|
1418 |
|newLeft newTop newWidth newHeight how
|
|
1419 |
mustRedrawBottomEdge mustRedrawRightEdge mustRepaintBottom
|
|
1420 |
mustRepaintRight sameOrigin oldWidth oldHeight|
|
0
|
1421 |
|
|
1422 |
newLeft := origin x.
|
|
1423 |
newTop := origin y.
|
15
|
1424 |
sameOrigin := ((newTop == top) and:[newLeft == left]).
|
|
1425 |
|
0
|
1426 |
newWidth := extent x.
|
|
1427 |
newHeight := extent y.
|
81
|
1428 |
|
94
|
1429 |
"
|
|
1430 |
X complains badly if you try to create/resize a view with
|
|
1431 |
a dimension <= 0 ... (although I think that 0 maks sense ...)
|
|
1432 |
"
|
|
1433 |
newWidth < 1 ifTrue:[
|
|
1434 |
newWidth := 1.
|
81
|
1435 |
].
|
94
|
1436 |
newHeight < 1 ifTrue:[
|
|
1437 |
newHeight := 1
|
81
|
1438 |
].
|
|
1439 |
|
0
|
1440 |
((newWidth == width) and:[newHeight == height]) ifTrue:[
|
72
|
1441 |
sameOrigin ifTrue:[^ self].
|
|
1442 |
^ self pixelOrigin:origin
|
0
|
1443 |
].
|
|
1444 |
top := newTop.
|
|
1445 |
left := newLeft.
|
|
1446 |
|
|
1447 |
mustRedrawBottomEdge := (level ~~ 0) and:[newHeight < height].
|
|
1448 |
mustRedrawRightEdge := (level ~~ 0) and:[newWidth < width].
|
|
1449 |
|
|
1450 |
((newHeight <= height) and:[newWidth <= width]) ifTrue:[
|
72
|
1451 |
how := #smaller
|
0
|
1452 |
].
|
|
1453 |
|
81
|
1454 |
"/ shown ifTrue:[ "4-nov-94 actually correct,"
|
|
1455 |
drawableId notNil ifTrue:[ "but theres a bug in menus when resized while hidden"
|
72
|
1456 |
mustRepaintRight := false.
|
|
1457 |
mustRepaintBottom := false.
|
|
1458 |
(level ~~ 0) ifTrue:[
|
|
1459 |
"clear the old edges"
|
|
1460 |
|
|
1461 |
newWidth > width ifTrue:[
|
|
1462 |
self clipRect:nil.
|
|
1463 |
self paint:viewBackground.
|
81
|
1464 |
self fillDeviceRectangleX:(width - margin)
|
|
1465 |
y:0
|
|
1466 |
width:margin
|
|
1467 |
height:height.
|
72
|
1468 |
mustRepaintRight := true.
|
|
1469 |
oldWidth := width
|
|
1470 |
].
|
|
1471 |
newHeight > height ifTrue:[
|
|
1472 |
self clipRect:nil.
|
|
1473 |
self paint:viewBackground.
|
81
|
1474 |
self fillDeviceRectangleX:0
|
|
1475 |
y:(height - margin)
|
|
1476 |
width:width
|
|
1477 |
height:margin.
|
72
|
1478 |
mustRepaintBottom := true.
|
|
1479 |
oldHeight := height
|
|
1480 |
]
|
|
1481 |
].
|
|
1482 |
|
|
1483 |
width := newWidth.
|
|
1484 |
height := newHeight.
|
|
1485 |
|
|
1486 |
self setInnerClip.
|
|
1487 |
|
|
1488 |
"if view becomes smaller, send sizeChanged first"
|
|
1489 |
(how == #smaller) ifTrue:[
|
|
1490 |
self sizeChanged:how
|
|
1491 |
].
|
|
1492 |
|
|
1493 |
"have to tell X, when extent of view is changed"
|
|
1494 |
sameOrigin ifTrue:[
|
|
1495 |
device resizeWindow:drawableId width:width height:height.
|
|
1496 |
] ifFalse:[
|
|
1497 |
"claus: some xservers seem to do better when resizing
|
|
1498 |
first ...."
|
|
1499 |
"
|
|
1500 |
(how == #smaller) ifTrue:[
|
|
1501 |
device resizeWindow:drawableId width:width height:height.
|
|
1502 |
device moveWindow:drawableId x:left y:top
|
|
1503 |
] ifFalse:[
|
|
1504 |
device moveResizeWindow:drawableId x:left y:top width:width height:height
|
|
1505 |
].
|
15
|
1506 |
"
|
72
|
1507 |
device moveResizeWindow:drawableId x:left y:top
|
|
1508 |
width:width height:height.
|
15
|
1509 |
" "
|
72
|
1510 |
].
|
|
1511 |
|
|
1512 |
"if view becomes bigger, send sizeChanged after"
|
|
1513 |
(how ~~ #smaller) ifTrue:[
|
|
1514 |
self sizeChanged:how
|
|
1515 |
].
|
|
1516 |
|
|
1517 |
(mustRedrawBottomEdge or:[mustRedrawRightEdge]) ifTrue:[
|
|
1518 |
self clipRect:nil.
|
|
1519 |
mustRedrawBottomEdge ifTrue:[
|
|
1520 |
self drawBottomEdge
|
|
1521 |
].
|
|
1522 |
mustRedrawRightEdge ifTrue:[
|
|
1523 |
self drawRightEdge
|
|
1524 |
].
|
|
1525 |
self clipRect:innerClipRect
|
|
1526 |
].
|
81
|
1527 |
|
72
|
1528 |
mustRepaintRight ifTrue:[
|
81
|
1529 |
self redrawDeviceX:(oldWidth - margin)
|
|
1530 |
y:0
|
|
1531 |
width:margin
|
|
1532 |
height:height.
|
72
|
1533 |
].
|
|
1534 |
mustRepaintBottom ifTrue:[
|
81
|
1535 |
self redrawDeviceX:0
|
|
1536 |
y:(oldHeight - margin)
|
|
1537 |
width:width
|
|
1538 |
height:margin.
|
72
|
1539 |
].
|
0
|
1540 |
] ifFalse:[
|
72
|
1541 |
"otherwise memorize the need for a sizeChanged message"
|
|
1542 |
|
|
1543 |
width := newWidth.
|
|
1544 |
height := newHeight.
|
|
1545 |
sameOrigin ifFalse:[
|
|
1546 |
originChanged := true.
|
|
1547 |
].
|
|
1548 |
extentChanged := true
|
0
|
1549 |
]
|
|
1550 |
!
|
|
1551 |
|
118
|
1552 |
cornerFromRelativeCorner
|
|
1553 |
"compute & return pixel corner from relativeCorner"
|
|
1554 |
|
|
1555 |
^ self cornerFromRelativeCorner:relativeCorner
|
|
1556 |
!
|
|
1557 |
|
72
|
1558 |
pointFromRelative:p
|
|
1559 |
"compute absolute coordinate from p"
|
|
1560 |
|
|
1561 |
|newX newY rel inRect bw superWidth superHeight superLeft superTop |
|
|
1562 |
|
|
1563 |
bw := borderWidth.
|
|
1564 |
|
|
1565 |
superView isNil ifTrue:[
|
116
|
1566 |
superWidth := device width + bw.
|
|
1567 |
superHeight := device height + bw.
|
72
|
1568 |
superLeft := superTop := 0.
|
|
1569 |
] ifFalse:[
|
|
1570 |
inRect := superView viewRectangle.
|
116
|
1571 |
superWidth := inRect width.
|
|
1572 |
superHeight := inRect height.
|
72
|
1573 |
superLeft := inRect left.
|
|
1574 |
superTop := inRect top.
|
|
1575 |
].
|
|
1576 |
|
|
1577 |
rel := p x.
|
|
1578 |
rel isInteger ifTrue:[
|
|
1579 |
newX := rel
|
|
1580 |
] ifFalse:[
|
116
|
1581 |
newX := (rel * superWidth) asInteger + superLeft.
|
72
|
1582 |
(bw ~~ 0) ifTrue:[
|
|
1583 |
rel ~= 1.0 ifTrue:[
|
|
1584 |
newX := newX - bw
|
|
1585 |
]
|
|
1586 |
]
|
|
1587 |
].
|
|
1588 |
|
|
1589 |
rel := p y.
|
|
1590 |
rel isInteger ifTrue:[
|
|
1591 |
newY := rel
|
|
1592 |
] ifFalse:[
|
116
|
1593 |
newY := (rel * superHeight) asInteger + superTop.
|
72
|
1594 |
(bw ~~ 0) ifTrue:[
|
|
1595 |
rel ~= 1.0 ifTrue:[
|
|
1596 |
newY := newY - bw
|
|
1597 |
]
|
|
1598 |
]
|
|
1599 |
].
|
|
1600 |
^ newX @ newY
|
|
1601 |
!
|
|
1602 |
|
118
|
1603 |
pixelCorner:corner
|
|
1604 |
"set the views corner in pixels"
|
|
1605 |
|
|
1606 |
|w h|
|
|
1607 |
|
|
1608 |
w := corner x - left.
|
|
1609 |
h := corner y - top.
|
|
1610 |
self pixelOrigin:(left @ top) extent:(w @ h)
|
81
|
1611 |
!
|
|
1612 |
|
|
1613 |
originFromRelativeOrigin:aPoint
|
|
1614 |
"compute & return pixel origin from relativeOrigin, aPoint"
|
0
|
1615 |
|
123
|
1616 |
|p l t|
|
72
|
1617 |
|
81
|
1618 |
p := self pointFromRelative:aPoint.
|
72
|
1619 |
|
82
|
1620 |
insets isNil ifTrue:[
|
|
1621 |
^ p
|
72
|
1622 |
].
|
82
|
1623 |
l := insets at:1.
|
|
1624 |
t := insets at:2.
|
|
1625 |
|
|
1626 |
"/ l := t := 0.
|
|
1627 |
"/ leftInset notNil ifTrue:[
|
|
1628 |
"/ l := leftInset
|
|
1629 |
"/ ].
|
|
1630 |
"/ topInset notNil ifTrue:[
|
|
1631 |
"/ t := topInset
|
|
1632 |
"/ ].
|
72
|
1633 |
((l ~~ 0) or:[t ~~ 0]) ifTrue:[
|
123
|
1634 |
^ (p x + l) @ (p y + t)
|
72
|
1635 |
].
|
|
1636 |
^ p
|
|
1637 |
!
|
|
1638 |
|
81
|
1639 |
cornerFromRelativeCorner:aPoint
|
|
1640 |
"compute & return pixel corner from a relativeCorner, aPoint"
|
0
|
1641 |
|
123
|
1642 |
|p r b bw|
|
72
|
1643 |
|
81
|
1644 |
p := self pointFromRelative:aPoint.
|
72
|
1645 |
|
|
1646 |
bw := borderWidth.
|
82
|
1647 |
insets isNil ifTrue:[
|
|
1648 |
bw == 0 ifTrue:[
|
|
1649 |
^ p
|
|
1650 |
].
|
|
1651 |
^ (p x - bw) @ (p y - bw)
|
72
|
1652 |
].
|
87
|
1653 |
r := (insets at:3) + bw.
|
|
1654 |
b := (insets at:4) + bw.
|
82
|
1655 |
|
|
1656 |
"/ r := b := bw.
|
|
1657 |
"/ rightInset notNil ifTrue:[
|
|
1658 |
"/ r := rightInset + bw
|
|
1659 |
"/ ].
|
|
1660 |
"/ bottomInset notNil ifTrue:[
|
|
1661 |
"/ b := bottomInset + bw
|
|
1662 |
"/ ].
|
72
|
1663 |
((r ~~ 0) or:[b ~~ 0]) ifTrue:[
|
123
|
1664 |
^ (p x - r) @ (p y - b)
|
72
|
1665 |
].
|
|
1666 |
^ p
|
|
1667 |
!
|
|
1668 |
|
118
|
1669 |
pixelOrigin:origin corner:corner
|
|
1670 |
"set the views origin and extent in pixels"
|
|
1671 |
|
|
1672 |
|w h|
|
|
1673 |
|
|
1674 |
w := corner x - origin x.
|
|
1675 |
h := corner y - origin y.
|
|
1676 |
self pixelOrigin:origin extent:(w @ h)
|
|
1677 |
!
|
|
1678 |
|
81
|
1679 |
extentFromRelativeExtent
|
|
1680 |
"compute & return pixel extent from relativeExtent"
|
|
1681 |
|
|
1682 |
^ self extentFromRelativeExtent:relativeExtent
|
42
|
1683 |
!
|
|
1684 |
|
81
|
1685 |
extentFromRelativeExtent:aPoint
|
|
1686 |
"compute & return pixel extent from relativeExtent, aPoint"
|
42
|
1687 |
|
121
|
1688 |
|rel newX newY inRect bw2 i|
|
0
|
1689 |
|
41
|
1690 |
superView isNil ifTrue:[
|
72
|
1691 |
inRect := 0@0 extent:device extent
|
41
|
1692 |
] ifFalse:[
|
72
|
1693 |
inRect := superView viewRectangle.
|
41
|
1694 |
].
|
|
1695 |
|
0
|
1696 |
bw2 := borderWidth * 2.
|
42
|
1697 |
|
81
|
1698 |
rel := aPoint x.
|
0
|
1699 |
(rel isMemberOf:Float) ifTrue:[
|
72
|
1700 |
newX := (rel * (inRect width + bw2)) asInteger + inRect left.
|
|
1701 |
(borderWidth ~~ 0) ifTrue:[
|
|
1702 |
newX := newX - borderWidth
|
|
1703 |
].
|
0
|
1704 |
] ifFalse:[
|
72
|
1705 |
newX := rel
|
0
|
1706 |
].
|
42
|
1707 |
|
81
|
1708 |
rel := aPoint y.
|
0
|
1709 |
(rel isMemberOf:Float) ifTrue:[
|
72
|
1710 |
newY := (rel * (inRect height + bw2)) asInteger + inRect top.
|
|
1711 |
(borderWidth ~~ 0) ifTrue:[
|
|
1712 |
newY := newY - borderWidth
|
|
1713 |
].
|
0
|
1714 |
] ifFalse:[
|
72
|
1715 |
newY := rel
|
0
|
1716 |
].
|
42
|
1717 |
|
82
|
1718 |
insets notNil ifTrue:[
|
123
|
1719 |
i := insets at:1. "top"
|
121
|
1720 |
(i ~~ 0) ifTrue:[
|
|
1721 |
newX := newX - i
|
|
1722 |
].
|
123
|
1723 |
i := insets at:3. "left"
|
121
|
1724 |
(i ~~ 0) ifTrue:[
|
|
1725 |
newX := newX - i
|
82
|
1726 |
].
|
123
|
1727 |
i := insets at:2. "right"
|
121
|
1728 |
(i ~~ 0) ifTrue:[
|
|
1729 |
newY := newY - i
|
|
1730 |
].
|
123
|
1731 |
i := insets at:4. "bottom"
|
121
|
1732 |
(i ~~ 0) ifTrue:[
|
|
1733 |
newY := newY - i
|
82
|
1734 |
].
|
46
|
1735 |
].
|
42
|
1736 |
^ newX @ newY
|
0
|
1737 |
!
|
|
1738 |
|
118
|
1739 |
setBorderColor
|
|
1740 |
"set my borderColor"
|
|
1741 |
|
|
1742 |
|id dither|
|
|
1743 |
|
|
1744 |
drawableId notNil ifTrue:[
|
|
1745 |
borderColor := borderColor on:device.
|
|
1746 |
id := borderColor colorId.
|
|
1747 |
id notNil ifTrue:[
|
|
1748 |
device setWindowBorderColor:id in:drawableId
|
|
1749 |
] ifFalse:[
|
|
1750 |
dither := borderColor ditherForm.
|
|
1751 |
dither notNil ifTrue:[
|
|
1752 |
device setWindowBorderPixmap:(dither id) in:drawableId
|
|
1753 |
] ifFalse:[
|
|
1754 |
'bad borderColor' errorPrintNewline
|
|
1755 |
]
|
|
1756 |
]
|
|
1757 |
]
|
|
1758 |
!
|
|
1759 |
|
0
|
1760 |
dimensionFromViewport
|
|
1761 |
"define my origin/extend from viewport"
|
|
1762 |
|
|
1763 |
|relW relH relX relY winW winH org ext|
|
|
1764 |
|
|
1765 |
superView notNil ifTrue:[
|
72
|
1766 |
superView window isNil ifTrue:[
|
0
|
1767 |
"
|
72
|
1768 |
v := superView.
|
|
1769 |
(v notNil and:[v window isNil]) whileTrue:[
|
|
1770 |
v := v superview
|
|
1771 |
].
|
|
1772 |
v notNil ifTrue:[
|
|
1773 |
w := v window
|
|
1774 |
].
|
0
|
1775 |
"
|
|
1776 |
"
|
72
|
1777 |
winW := 1.
|
|
1778 |
winH := 1
|
0
|
1779 |
"
|
72
|
1780 |
winW := superView width.
|
|
1781 |
winH := superView height.
|
|
1782 |
|
|
1783 |
] ifFalse:[
|
|
1784 |
winW := superView window width.
|
|
1785 |
winH := superView window height
|
|
1786 |
].
|
|
1787 |
relW := (viewport width / winW) asFloat.
|
|
1788 |
relH := (viewport height / winH) asFloat.
|
|
1789 |
relX := (viewport left / winW) asFloat.
|
|
1790 |
relY := (viewport top / winH) asFloat.
|
|
1791 |
"bad coding style ... misuse other method"
|
|
1792 |
relativeOrigin := (relX @ relY).
|
|
1793 |
org := self originFromRelativeOrigin.
|
|
1794 |
relativeOrigin := nil.
|
|
1795 |
|
|
1796 |
"bad coding style ...misuse other method"
|
|
1797 |
relativeExtent := (relW @ relH).
|
|
1798 |
ext := self extentFromRelativeExtent.
|
|
1799 |
relativeExtent := nil.
|
|
1800 |
|
|
1801 |
self pixelOrigin:org extent:ext.
|
0
|
1802 |
]
|
118
|
1803 |
! !
|
|
1804 |
|
|
1805 |
!View methodsFor:'accessing-transformation'!
|
|
1806 |
|
|
1807 |
transformation
|
|
1808 |
"return the transformation"
|
|
1809 |
|
|
1810 |
|vP|
|
|
1811 |
|
|
1812 |
transformation isNil ifTrue:[
|
|
1813 |
"
|
|
1814 |
fake a transformation, if I have a non-nil window
|
|
1815 |
"
|
|
1816 |
window notNil ifTrue:[
|
|
1817 |
superView isNil ifTrue:[
|
|
1818 |
vP := (0@0 extent:self extent)
|
72
|
1819 |
] ifFalse:[
|
118
|
1820 |
vP := (self origin extent:self extent)
|
|
1821 |
].
|
|
1822 |
^ WindowingTransformation
|
|
1823 |
window:window
|
|
1824 |
viewport:vP
|
|
1825 |
]
|
|
1826 |
].
|
|
1827 |
^ transformation
|
|
1828 |
!
|
|
1829 |
|
|
1830 |
viewRectangle
|
|
1831 |
"return the inside area"
|
|
1832 |
|
|
1833 |
|m2|
|
|
1834 |
|
|
1835 |
innerClipRect notNil ifTrue:[
|
|
1836 |
^ innerClipRect
|
|
1837 |
].
|
|
1838 |
m2 := margin + margin.
|
|
1839 |
|
|
1840 |
^ (margin @ margin) extent:((width - m2) @ (height - m2))
|
|
1841 |
!
|
|
1842 |
|
|
1843 |
window
|
|
1844 |
"return my window (i.e. logical coordinate space).
|
|
1845 |
If there is no window, return the extent."
|
|
1846 |
|
|
1847 |
window isNil ifTrue:[^ width @ height].
|
|
1848 |
^ window
|
|
1849 |
!
|
|
1850 |
|
|
1851 |
window:aRectangle
|
|
1852 |
"define my window (i.e. logical coordinate space)"
|
|
1853 |
|
|
1854 |
window := aRectangle.
|
|
1855 |
subViews notNil ifTrue:[
|
|
1856 |
subViews do:[:s |
|
|
1857 |
s superViewChangedSize
|
72
|
1858 |
]
|
|
1859 |
]
|
118
|
1860 |
|
|
1861 |
"
|
|
1862 |
viewport isNil ifTrue:[
|
|
1863 |
viewport := aRectangle.
|
46
|
1864 |
].
|
118
|
1865 |
"
|
|
1866 |
"
|
|
1867 |
superView notNil ifTrue:[
|
|
1868 |
self superViewChangedSize
|
|
1869 |
] ifFalse:[
|
|
1870 |
originChanged := true.
|
|
1871 |
extentChanged := true
|
0
|
1872 |
]
|
118
|
1873 |
"
|
|
1874 |
!
|
|
1875 |
|
|
1876 |
viewOrigin
|
|
1877 |
"return the viewOrigin; thats the coordinate of the contents
|
|
1878 |
which is shown topLeft in the view
|
|
1879 |
(i.e. the origin of the visible part of the contents)."
|
|
1880 |
|
|
1881 |
transformation isNil ifTrue:[
|
|
1882 |
^ 0@0
|
0
|
1883 |
].
|
118
|
1884 |
^ transformation translation negated
|
|
1885 |
!
|
|
1886 |
|
|
1887 |
setViewOrigin:aPoint
|
|
1888 |
"set the viewOrigin - i.e. virtually scroll without redrawing"
|
|
1889 |
|
|
1890 |
|p|
|
|
1891 |
|
|
1892 |
p := aPoint negated.
|
|
1893 |
transformation isNil ifTrue:[
|
|
1894 |
transformation := WindowingTransformation scale:1 translation:p
|
|
1895 |
] ifFalse:[
|
|
1896 |
transformation translation:p
|
60
|
1897 |
].
|
118
|
1898 |
clipRect notNil ifTrue:[
|
|
1899 |
self setInnerClip.
|
0
|
1900 |
].
|
118
|
1901 |
!
|
|
1902 |
|
|
1903 |
viewport:aRectangle
|
|
1904 |
"define my extend in my superviews coordinate-system."
|
|
1905 |
|
|
1906 |
"/ |relW relH relX relY winW winH|
|
|
1907 |
|
|
1908 |
viewport := aRectangle.
|
|
1909 |
self dimensionFromViewport
|
|
1910 |
"/
|
|
1911 |
"/ superView notNil ifTrue:[
|
|
1912 |
"/ superView window isNil ifTrue:[
|
|
1913 |
"/ winW := 1.
|
|
1914 |
"/ winH := 1
|
|
1915 |
"/ ] ifFalse:[
|
|
1916 |
"/ winW := superView window width.
|
|
1917 |
"/ winH := superView window height
|
|
1918 |
"/ ].
|
|
1919 |
"/ relW := (aRectangle width / winW) asFloat.
|
|
1920 |
"/ relH := (aRectangle height / winH) asFloat.
|
|
1921 |
"/ relX := (aRectangle left / winW) asFloat.
|
|
1922 |
"/ relY := (aRectangle top / winH) asFloat.
|
|
1923 |
"/ self origin:(relX @ relY) extent:(relW @ relH)
|
|
1924 |
"/ ]
|
|
1925 |
"/
|
|
1926 |
!
|
|
1927 |
|
|
1928 |
window:aRectangle viewport:vRect
|
|
1929 |
window := aRectangle.
|
|
1930 |
self viewport:vRect.
|
|
1931 |
subViews notNil ifTrue:[
|
|
1932 |
subViews do:[:s |
|
|
1933 |
s superViewChangedSize
|
89
|
1934 |
]
|
20
|
1935 |
]
|
60
|
1936 |
!
|
|
1937 |
|
118
|
1938 |
scale
|
|
1939 |
"return the scale factor (as point) of the transformation"
|
|
1940 |
|
|
1941 |
transformation isNil ifTrue:[^ 1].
|
|
1942 |
^ transformation scale
|
|
1943 |
!
|
|
1944 |
|
|
1945 |
scale:aPoint
|
|
1946 |
"set the scale factor of the transformation"
|
|
1947 |
|
|
1948 |
transformation isNil ifTrue:[
|
|
1949 |
aPoint = 1 ifTrue:[^ self].
|
|
1950 |
transformation := WindowingTransformation scale:aPoint translation:0
|
|
1951 |
].
|
|
1952 |
|
|
1953 |
transformation scale:aPoint.
|
|
1954 |
self computeInnerClip
|
|
1955 |
!
|
|
1956 |
|
|
1957 |
xOriginOfContents
|
|
1958 |
"return the x coordinate of the viewOrigin in pixels;
|
|
1959 |
used by scrollBars to compute thumb position within the document."
|
|
1960 |
|
|
1961 |
^ self viewOrigin x
|
|
1962 |
!
|
|
1963 |
|
|
1964 |
yOriginOfContents
|
|
1965 |
"return the y coordinate of the viewOrigin in pixels;
|
|
1966 |
used by scrollBars to compute thumb position within the document."
|
|
1967 |
|
|
1968 |
^ self viewOrigin y
|
|
1969 |
!
|
|
1970 |
|
|
1971 |
heightOfContents
|
|
1972 |
"return the height of the contents in logical units
|
|
1973 |
- defaults to views visible area here.
|
|
1974 |
This method MUST be redefined in all view classess which are
|
|
1975 |
going to be scrolled AND show data which has different size than
|
|
1976 |
the view. For example, a view showing A4-size documents should return
|
|
1977 |
the number of vertical pixels such a document has on this device.
|
|
1978 |
A view showing a bitmap of height 1000 should return 1000.
|
|
1979 |
If not redefined, scrollbars have no way of knowing the actual size
|
|
1980 |
of the contents being shown. This is called by scrollBars to compute
|
|
1981 |
the relative height of the document vs. the views actual size.
|
|
1982 |
The value returned here must be based on a scale of 1, since users
|
|
1983 |
of this will scale as appropriate."
|
|
1984 |
|
|
1985 |
^ self innerHeight max:(self maxSubViewBottom)
|
|
1986 |
!
|
|
1987 |
|
|
1988 |
widthOfContents
|
|
1989 |
|
|
1990 |
^ self innerWidth max:(self maxSubViewRight)
|
|
1991 |
|
|
1992 |
!
|
|
1993 |
|
|
1994 |
maxSubViewBottom
|
|
1995 |
"/ subViews isNil ifTrue:[^ 0].
|
|
1996 |
"/ ^ subViews inject:0 into:[:maxSoFar :sub | (sub top + sub height) max:maxSoFar].
|
|
1997 |
^ 0
|
|
1998 |
!
|
|
1999 |
|
|
2000 |
maxSubViewRight
|
|
2001 |
"/ subViews isNil ifTrue:[^ 0].
|
|
2002 |
"/ ^ subViews inject:0 into:[:maxSoFar :sub | (sub left + sub width) max:maxSoFar].
|
|
2003 |
^ 0
|
72
|
2004 |
! !
|
|
2005 |
|
118
|
2006 |
!View methodsFor:'accessing misc'!
|
|
2007 |
|
|
2008 |
clipRect:aRectangle
|
|
2009 |
"set the clipping rectangle for drawing (in logical coordinates);
|
|
2010 |
a nil argument turn off clipping (i.e. whole view is drawable).
|
|
2011 |
Redefined to care for any margin."
|
|
2012 |
|
|
2013 |
|x y w h|
|
|
2014 |
|
|
2015 |
aRectangle isNil ifTrue:[
|
|
2016 |
clipRect isNil ifTrue:[^ self].
|
|
2017 |
gcId notNil ifTrue:[
|
|
2018 |
device noClipIn:gcId
|
|
2019 |
]
|
0
|
2020 |
] ifFalse:[
|
118
|
2021 |
clipRect notNil ifTrue:[
|
|
2022 |
(clipRect = aRectangle) ifTrue:[^ self]
|
|
2023 |
].
|
|
2024 |
gcId notNil ifTrue:[
|
|
2025 |
x := aRectangle left.
|
|
2026 |
y := aRectangle top.
|
|
2027 |
w := aRectangle width.
|
|
2028 |
h := aRectangle height.
|
|
2029 |
transformation notNil ifTrue:[
|
|
2030 |
x := transformation applyToX:x.
|
|
2031 |
y := transformation applyToY:y.
|
|
2032 |
w := transformation applyScaleX:w.
|
|
2033 |
h := transformation applyScaleY:h.
|
|
2034 |
].
|
|
2035 |
(x isMemberOf:SmallInteger) ifFalse:[
|
|
2036 |
w := w + (x - x truncated).
|
|
2037 |
x := x truncated
|
|
2038 |
].
|
|
2039 |
(y isMemberOf:SmallInteger) ifFalse:[
|
|
2040 |
h := h + (y - y truncated).
|
|
2041 |
y := y truncated
|
|
2042 |
].
|
|
2043 |
(w isMemberOf:SmallInteger) ifFalse:[
|
|
2044 |
w := w truncated + 1
|
|
2045 |
].
|
|
2046 |
(h isMemberOf:SmallInteger) ifFalse:[
|
|
2047 |
h := h truncated + 1
|
|
2048 |
].
|
|
2049 |
x < margin ifTrue:[
|
|
2050 |
x := margin.
|
|
2051 |
].
|
|
2052 |
y < margin ifTrue:[
|
|
2053 |
y := margin.
|
|
2054 |
].
|
|
2055 |
x + w - 1 >= (width-margin) ifTrue:[
|
|
2056 |
w := width - margin - x
|
|
2057 |
].
|
|
2058 |
y + h - 1 >= (height-margin) ifTrue:[
|
|
2059 |
h := height - margin - y
|
|
2060 |
].
|
|
2061 |
device setClipX:x y:y width:w height:h in:gcId
|
72
|
2062 |
]
|
0
|
2063 |
].
|
118
|
2064 |
clipRect := aRectangle
|
|
2065 |
! !
|
|
2066 |
|
|
2067 |
!View methodsFor:'ST-80 compatibility'!
|
|
2068 |
|
|
2069 |
sensor
|
|
2070 |
"return the views sensor"
|
|
2071 |
|
|
2072 |
windowGroup notNil ifTrue:[
|
|
2073 |
^ windowGroup sensor.
|
|
2074 |
].
|
|
2075 |
^ nil
|
|
2076 |
!
|
|
2077 |
|
|
2078 |
update:aspect
|
|
2079 |
"an update request - ignored here. Can be redefined in subclasses"
|
|
2080 |
|
|
2081 |
^ self
|
|
2082 |
!
|
|
2083 |
|
|
2084 |
on:aModel aspect:aspect change:change list:list menu:menu
|
|
2085 |
"ST-80 compatibility"
|
|
2086 |
|
|
2087 |
aspectSymbol := aspect.
|
|
2088 |
changeSymbol := change.
|
|
2089 |
menuSymbol := menu.
|
|
2090 |
self model:aModel
|
|
2091 |
!
|
|
2092 |
|
|
2093 |
update
|
|
2094 |
"an update request - ignored here. Can be redefined in subclasses."
|
|
2095 |
|
|
2096 |
^ self
|
|
2097 |
!
|
|
2098 |
|
|
2099 |
update:aspect with:aParameter from:changedObject
|
|
2100 |
"an update request"
|
|
2101 |
|
|
2102 |
aspect == #sizeOfView ifTrue:[
|
|
2103 |
"one of the views we depend on changed its size"
|
|
2104 |
^ self superViewChangedSize.
|
0
|
2105 |
].
|
118
|
2106 |
^super update:aspect with:aParameter from:changedObject
|
|
2107 |
! !
|
|
2108 |
|
|
2109 |
!View methodsFor:'accessing-misc'!
|
|
2110 |
|
|
2111 |
shown
|
|
2112 |
"return true if the view is shown; false if hidden"
|
|
2113 |
|
|
2114 |
^ shown
|
|
2115 |
!
|
|
2116 |
|
|
2117 |
inputOnly
|
|
2118 |
"return true, if this view is an input-only view;
|
|
2119 |
input only views are transparent and can be layed on top of a view to
|
|
2120 |
catch its input"
|
|
2121 |
|
|
2122 |
^ false
|
|
2123 |
!
|
|
2124 |
|
|
2125 |
createOnTop
|
|
2126 |
"return true, if this view should be put on top (raised) automatically.
|
|
2127 |
usually this is true for alertBoxes etc."
|
|
2128 |
|
|
2129 |
^ false
|
|
2130 |
!
|
|
2131 |
|
|
2132 |
is3D
|
|
2133 |
"return true, if my style is some kind of 3D style - will change"
|
|
2134 |
|
|
2135 |
^ StyleSheet is3D
|
|
2136 |
!
|
|
2137 |
|
|
2138 |
raise
|
|
2139 |
"bring to front"
|
|
2140 |
|
|
2141 |
drawableId isNil ifTrue:[self create].
|
|
2142 |
device raiseWindow:drawableId
|
|
2143 |
!
|
|
2144 |
|
|
2145 |
viewGravity:gravity
|
|
2146 |
"set the viewGravity - thats the direction where the view will move
|
|
2147 |
when the superView is resized."
|
|
2148 |
|
|
2149 |
viewGravity ~~ gravity ifTrue:[
|
|
2150 |
viewGravity := gravity.
|
|
2151 |
drawableId notNil ifTrue:[
|
|
2152 |
device setWindowGravity:gravity in:drawableId
|
|
2153 |
]
|
|
2154 |
]
|
|
2155 |
!
|
|
2156 |
|
|
2157 |
viewGravity
|
|
2158 |
"return the viewGravity - thats the direction where the view will move
|
|
2159 |
when the superView is resized."
|
|
2160 |
|
|
2161 |
^ viewGravity
|
|
2162 |
!
|
|
2163 |
|
|
2164 |
hidden:aBoolean
|
|
2165 |
"if the argument is true, the receiver view will not
|
|
2166 |
be realized automatically when superview is realized"
|
|
2167 |
|
|
2168 |
hidden := aBoolean
|
|
2169 |
!
|
|
2170 |
|
|
2171 |
bitGravity
|
|
2172 |
"return the bitGravity - thats the direction where the contents will move
|
|
2173 |
when the the view is resized."
|
|
2174 |
|
|
2175 |
^ bitGravity
|
|
2176 |
!
|
|
2177 |
|
|
2178 |
bitGravity:gravity
|
|
2179 |
"set the bitGravity - thats the direction where the contents will move
|
|
2180 |
when the view is resized."
|
|
2181 |
|
|
2182 |
bitGravity ~~ gravity ifTrue:[
|
|
2183 |
bitGravity := gravity.
|
|
2184 |
drawableId notNil ifTrue:[
|
|
2185 |
device setBitGravity:gravity in:drawableId
|
|
2186 |
]
|
0
|
2187 |
]
|
|
2188 |
!
|
|
2189 |
|
118
|
2190 |
canDrop:anObjectOrCollection
|
|
2191 |
"return true, if anObjectOrCollection can be
|
|
2192 |
dropped in the receiver. This method should be
|
|
2193 |
redefined in views which can take objects"
|
|
2194 |
|
|
2195 |
^ false
|
|
2196 |
!
|
|
2197 |
|
|
2198 |
isCollapsed
|
|
2199 |
"ST80 compatibility: return true if the view is not shown (i.e. iconified)"
|
|
2200 |
|
|
2201 |
^ shown not
|
|
2202 |
!
|
|
2203 |
|
|
2204 |
hidden
|
|
2205 |
"return true, if the view does not want to be realized
|
|
2206 |
automatically when superview is realized"
|
|
2207 |
|
|
2208 |
^ hidden
|
|
2209 |
!
|
|
2210 |
|
|
2211 |
lower
|
|
2212 |
"bring to back"
|
|
2213 |
|
|
2214 |
drawableId isNil ifTrue:[self create].
|
|
2215 |
device lowerWindow:drawableId
|
|
2216 |
! !
|
|
2217 |
|
|
2218 |
!View methodsFor:'initialization'!
|
|
2219 |
|
|
2220 |
defaultControllerClass
|
|
2221 |
^ nil "/ Controller
|
|
2222 |
!
|
|
2223 |
|
|
2224 |
initEvents
|
|
2225 |
"will be sent by create - can be redefined by subclasses to enable
|
|
2226 |
view events"
|
|
2227 |
|
|
2228 |
^ self
|
|
2229 |
!
|
|
2230 |
|
|
2231 |
initialize
|
|
2232 |
"initialize all state of the view - usually redefined in subclasses,
|
|
2233 |
but always doing a 'super initialize'. Each class should setup its
|
|
2234 |
locals - and not forget the others.
|
|
2235 |
View setup is separated into two parts, the general setup done here
|
|
2236 |
and the style specific setup in initStyle. Each view should be prepared
|
|
2237 |
for a stylechange by being sent another initStyle with a new style value.
|
|
2238 |
(in this case, it should set all of its style-dependent things, but
|
|
2239 |
leave the state and contents as-is)"
|
|
2240 |
|
|
2241 |
|ext controllerClass|
|
|
2242 |
|
|
2243 |
super initialize.
|
|
2244 |
|
|
2245 |
font := DefaultFont.
|
|
2246 |
|
|
2247 |
shown := hidden := realized := false.
|
|
2248 |
|
|
2249 |
"fill in some defaults - some of them are usually redefined in subclasses
|
|
2250 |
initialize methods"
|
|
2251 |
|
|
2252 |
name := self class name asString asLowercaseFirst.
|
|
2253 |
ext := self class defaultExtent.
|
|
2254 |
|
|
2255 |
level := 0.
|
|
2256 |
margin := 0.
|
|
2257 |
|
|
2258 |
resources := self class classResources.
|
|
2259 |
|
|
2260 |
self initStyle.
|
|
2261 |
|
|
2262 |
left := 0.
|
|
2263 |
top := 0.
|
|
2264 |
width := ext x.
|
|
2265 |
height := ext y.
|
|
2266 |
"/ leftInset := 0.
|
|
2267 |
"/ topInset := 0.
|
|
2268 |
"/ rightInset := 0.
|
|
2269 |
"/ bottomInset := 0.
|
|
2270 |
|
|
2271 |
originChanged := extentChanged := false.
|
|
2272 |
bitGravity := nil.
|
|
2273 |
viewGravity := nil.
|
|
2274 |
|
|
2275 |
controllerClass := self defaultControllerClass.
|
|
2276 |
controllerClass notNil ifTrue:[
|
|
2277 |
controller := controllerClass new.
|
|
2278 |
controller view:self.
|
|
2279 |
model notNil ifTrue:[
|
|
2280 |
controller model:model
|
|
2281 |
]
|
81
|
2282 |
].
|
118
|
2283 |
!
|
|
2284 |
|
|
2285 |
initStyle
|
|
2286 |
"this method sets up all style dependent things"
|
|
2287 |
|
|
2288 |
"
|
|
2289 |
when coming here the first time, we read the styleSheet
|
|
2290 |
and keep the values in fast class variables
|
|
2291 |
"
|
|
2292 |
StyleSheet isNil ifTrue:[
|
|
2293 |
self class updateStyleCache
|
0
|
2294 |
].
|
118
|
2295 |
|
|
2296 |
style := DefaultStyle.
|
|
2297 |
|
|
2298 |
borderWidth := DefaultBorderWidth.
|
|
2299 |
borderWidth isNil ifTrue:[borderWidth := 1].
|
|
2300 |
|
|
2301 |
viewBackground := DefaultViewBackgroundColor "on:device".
|
|
2302 |
|
|
2303 |
DefaultLightColor notNil ifTrue:[
|
|
2304 |
lightColor := DefaultLightColor.
|
|
2305 |
] ifFalse:[
|
|
2306 |
device hasGreyscales ifTrue:[
|
|
2307 |
DefaultLightColor := lightColor := viewBackground lightened.
|
|
2308 |
] ifFalse:[
|
|
2309 |
"
|
|
2310 |
this seems strange: on B&W light color is darker than
|
|
2311 |
normal viewBackground (White) to make the boundary of
|
|
2312 |
the view visible
|
|
2313 |
"
|
|
2314 |
lightColor := Color grey:50
|
|
2315 |
]
|
0
|
2316 |
].
|
118
|
2317 |
DefaultShadowColor notNil ifTrue:[
|
|
2318 |
shadowColor := DefaultShadowColor.
|
|
2319 |
] ifFalse:[
|
|
2320 |
shadowColor := Black
|
|
2321 |
].
|
|
2322 |
|
|
2323 |
lightColor := lightColor "on:device".
|
|
2324 |
shadowColor := shadowColor "on:device".
|
|
2325 |
borderColor := DefaultBorderColor " on:device".
|
|
2326 |
font := DefaultFont on:device.
|
|
2327 |
!
|
|
2328 |
|
|
2329 |
prepareForReinit
|
|
2330 |
super prepareForReinit.
|
|
2331 |
windowGroup notNil ifTrue:[
|
|
2332 |
windowGroup reinitialize
|
0
|
2333 |
]
|
|
2334 |
!
|
|
2335 |
|
118
|
2336 |
reinitialize
|
|
2337 |
"this is called right snapIn"
|
|
2338 |
|
|
2339 |
|myController|
|
|
2340 |
|
|
2341 |
"if I have already been reinited - return"
|
|
2342 |
drawableId notNil ifTrue:[
|
|
2343 |
^ self
|
|
2344 |
].
|
|
2345 |
|
|
2346 |
"
|
|
2347 |
superView must be there, first
|
|
2348 |
"
|
|
2349 |
superView notNil ifTrue:[
|
|
2350 |
superView id isNil ifTrue:[
|
|
2351 |
superView reinitialize
|
|
2352 |
]
|
|
2353 |
].
|
|
2354 |
|
|
2355 |
myController := controller.
|
|
2356 |
controller := nil.
|
|
2357 |
self recreate.
|
|
2358 |
|
|
2359 |
"if I was mapped, do it again"
|
|
2360 |
realized ifTrue:[
|
|
2361 |
"only remap if I have a superview - otherwise, I might be
|
|
2362 |
a hidden iconView or menu ..."
|
|
2363 |
superView notNil ifTrue:[
|
|
2364 |
"/ shown ifTrue:[
|
|
2365 |
device mapView:self id:drawableId iconified:false
|
|
2366 |
atX:left y:top width:width height:height
|
|
2367 |
"/ ].
|
72
|
2368 |
].
|
0
|
2369 |
].
|
118
|
2370 |
|
|
2371 |
"restore controller"
|
|
2372 |
controller := myController
|
|
2373 |
!
|
|
2374 |
|
|
2375 |
reinitStyle
|
|
2376 |
"this method is called for a style change"
|
|
2377 |
|
|
2378 |
|t|
|
|
2379 |
|
|
2380 |
self initStyle.
|
|
2381 |
drawableId notNil ifTrue:[
|
|
2382 |
"force a change"
|
|
2383 |
t := borderWidth. borderWidth := nil. self borderWidth:t.
|
|
2384 |
t := viewBackground. viewBackground := nil. self viewBackground:t.
|
|
2385 |
self clear.
|
|
2386 |
self redraw
|
0
|
2387 |
].
|
118
|
2388 |
! !
|
|
2389 |
|
|
2390 |
!View methodsFor:'accessing-hierarchy'!
|
|
2391 |
|
|
2392 |
superView:aView
|
|
2393 |
"set my superView to be aView"
|
|
2394 |
|
|
2395 |
superView := aView
|
|
2396 |
!
|
|
2397 |
|
|
2398 |
superView
|
|
2399 |
"return my superView"
|
|
2400 |
|
|
2401 |
^ superView
|
|
2402 |
!
|
|
2403 |
|
|
2404 |
subViews
|
|
2405 |
"return the collection of subviews"
|
|
2406 |
|
|
2407 |
^ subViews
|
|
2408 |
!
|
|
2409 |
|
|
2410 |
topView
|
|
2411 |
"return the topView - thats the one with no superview"
|
|
2412 |
|
|
2413 |
|v|
|
|
2414 |
|
|
2415 |
v := self.
|
|
2416 |
[v notNil] whileTrue:[
|
|
2417 |
v superView isNil ifTrue:[^ v].
|
|
2418 |
v := v superView
|
81
|
2419 |
].
|
118
|
2420 |
|
|
2421 |
^ nil
|
|
2422 |
!
|
|
2423 |
|
|
2424 |
subViews:aListOfViews
|
|
2425 |
"set the collection of subviews"
|
|
2426 |
|
|
2427 |
subViews := aListOfViews.
|
|
2428 |
subViews notNil ifTrue:[
|
|
2429 |
subViews do:[:view |
|
|
2430 |
view superView:self
|
|
2431 |
]
|
89
|
2432 |
]
|
0
|
2433 |
! !
|
|
2434 |
|
86
|
2435 |
!View methodsFor:'event handling'!
|
0
|
2436 |
|
|
2437 |
exposeX:x y:y width:w height:h
|
|
2438 |
"a low level redraw event from device
|
|
2439 |
- let subclass handle the redraw and take care of edges here"
|
|
2440 |
|
89
|
2441 |
|leftEdge topEdge rightEdge botEdge anyEdge nx ny nw nh old|
|
0
|
2442 |
|
|
2443 |
nw := w.
|
|
2444 |
nh := h.
|
|
2445 |
nx := x.
|
|
2446 |
ny := y.
|
|
2447 |
|
|
2448 |
anyEdge := false.
|
|
2449 |
|
83
|
2450 |
"
|
89
|
2451 |
check if there is a need to draw an edge (i.e. if margin is hit)
|
83
|
2452 |
"
|
0
|
2453 |
(margin ~~ 0) ifTrue:[
|
72
|
2454 |
leftEdge := false.
|
|
2455 |
topEdge := false.
|
|
2456 |
rightEdge := false.
|
|
2457 |
botEdge := false.
|
83
|
2458 |
transformation notNil ifTrue:[
|
|
2459 |
"
|
|
2460 |
need device coordinates for this test
|
|
2461 |
"
|
|
2462 |
nx := transformation applyToX:nx.
|
|
2463 |
ny := transformation applyToY:ny.
|
|
2464 |
nw := transformation applyScaleX:nw.
|
87
|
2465 |
nh := transformation applyScaleY:nh.
|
|
2466 |
].
|
89
|
2467 |
"
|
|
2468 |
adjust expose rectangle, to exclude the margin.
|
|
2469 |
Care for rounding errors ...
|
|
2470 |
"
|
87
|
2471 |
(nx isMemberOf:SmallInteger) ifFalse:[
|
89
|
2472 |
old := nx.
|
87
|
2473 |
nx := nx truncated.
|
89
|
2474 |
nw := nw + (nx - old).
|
87
|
2475 |
].
|
|
2476 |
(ny isMemberOf:SmallInteger) ifFalse:[
|
89
|
2477 |
old := ny.
|
87
|
2478 |
ny := ny truncated.
|
89
|
2479 |
nh := nh + (ny - old).
|
87
|
2480 |
].
|
|
2481 |
(nw isMemberOf:SmallInteger) ifFalse:[
|
|
2482 |
nw := nw truncated + 1
|
|
2483 |
].
|
|
2484 |
(nh isMemberOf:SmallInteger) ifFalse:[
|
|
2485 |
nh := nh truncated + 1
|
83
|
2486 |
].
|
89
|
2487 |
(nx < margin) ifTrue:[
|
|
2488 |
old := nx.
|
72
|
2489 |
nx := margin.
|
89
|
2490 |
nw := nw - (nx - old).
|
87
|
2491 |
leftEdge := anyEdge := true.
|
72
|
2492 |
].
|
89
|
2493 |
((nx + nw - 1) >= (width - margin)) ifTrue:[
|
72
|
2494 |
nw := (width - margin - nx).
|
87
|
2495 |
rightEdge := anyEdge := true.
|
72
|
2496 |
].
|
89
|
2497 |
(ny < margin) ifTrue:[
|
|
2498 |
old := ny.
|
72
|
2499 |
ny := margin.
|
89
|
2500 |
nh := nh - (ny - old).
|
87
|
2501 |
topEdge := anyEdge := true.
|
72
|
2502 |
].
|
89
|
2503 |
((ny + nh - 1) >= (height - margin)) ifTrue:[
|
72
|
2504 |
nh := (height - margin - ny).
|
87
|
2505 |
botEdge := anyEdge := true.
|
83
|
2506 |
].
|
|
2507 |
transformation notNil ifTrue:[
|
|
2508 |
"
|
|
2509 |
need logical coordinates for redraw
|
|
2510 |
"
|
|
2511 |
nx := transformation applyInverseToX:nx.
|
|
2512 |
ny := transformation applyInverseToY:ny.
|
|
2513 |
nw := transformation applyInverseScaleX:nw.
|
87
|
2514 |
nh := transformation applyInverseScaleY:nh.
|
83
|
2515 |
].
|
0
|
2516 |
].
|
|
2517 |
|
89
|
2518 |
"
|
|
2519 |
redraw inside area
|
|
2520 |
"
|
0
|
2521 |
self redrawX:nx y:ny width:nw height:nh.
|
|
2522 |
|
89
|
2523 |
"
|
|
2524 |
redraw edge(s)
|
|
2525 |
"
|
0
|
2526 |
anyEdge ifTrue:[
|
72
|
2527 |
self clipRect:nil.
|
|
2528 |
(topEdge and:[leftEdge and:[botEdge and:[rightEdge]]]) ifTrue:[
|
81
|
2529 |
self drawEdges
|
72
|
2530 |
] ifFalse:[
|
|
2531 |
topEdge ifTrue:[
|
|
2532 |
self drawTopEdge
|
|
2533 |
].
|
|
2534 |
leftEdge ifTrue:[
|
|
2535 |
self drawLeftEdge
|
|
2536 |
].
|
|
2537 |
botEdge ifTrue:[
|
|
2538 |
self drawBottomEdge
|
|
2539 |
].
|
|
2540 |
rightEdge ifTrue:[
|
|
2541 |
self drawRightEdge
|
|
2542 |
]
|
|
2543 |
].
|
|
2544 |
self clipRect:innerClipRect
|
0
|
2545 |
]
|
|
2546 |
!
|
|
2547 |
|
118
|
2548 |
superViewMapped
|
|
2549 |
"my superview was unmapped"
|
|
2550 |
|
|
2551 |
realized ifTrue:[
|
|
2552 |
shown := true.
|
|
2553 |
subViews notNil ifTrue:[
|
|
2554 |
subViews do:[:v |
|
|
2555 |
v superViewMapped
|
82
|
2556 |
]
|
|
2557 |
]
|
|
2558 |
].
|
118
|
2559 |
!
|
|
2560 |
|
|
2561 |
configureX:x y:y width:newWidth height:newHeight
|
|
2562 |
"my size has changed by window manager action"
|
|
2563 |
|
|
2564 |
|how anyEdge mustRedrawBottomEdge mustRedrawRightEdge|
|
|
2565 |
|
|
2566 |
left := x.
|
|
2567 |
top := y.
|
|
2568 |
((width ~~ newWidth) or:[height ~~ newHeight]) ifTrue:[
|
|
2569 |
realized ifFalse:[
|
|
2570 |
width := newWidth.
|
|
2571 |
height := newHeight.
|
|
2572 |
extentChanged := true.
|
|
2573 |
^ self
|
|
2574 |
].
|
|
2575 |
|
|
2576 |
((newWidth <= width) and:[newHeight <= height]) ifTrue:[
|
|
2577 |
how := #smaller
|
|
2578 |
].
|
|
2579 |
|
|
2580 |
level ~~ 0 ifTrue:[
|
|
2581 |
mustRedrawBottomEdge := newHeight < height.
|
|
2582 |
mustRedrawRightEdge := newWidth < width.
|
|
2583 |
anyEdge := mustRedrawBottomEdge or:[mustRedrawRightEdge]
|
|
2584 |
] ifFalse:[
|
|
2585 |
anyEdge := false
|
|
2586 |
].
|
|
2587 |
|
|
2588 |
width := newWidth.
|
|
2589 |
height := newHeight.
|
|
2590 |
|
|
2591 |
"recompute inner-clip if needed"
|
|
2592 |
self setInnerClip.
|
|
2593 |
|
|
2594 |
"
|
|
2595 |
must first process pending exposes;
|
|
2596 |
otherwise, those may be drawn at a wrong position
|
|
2597 |
"
|
|
2598 |
windowGroup notNil ifTrue:[
|
|
2599 |
windowGroup processExposeEvents
|
|
2600 |
].
|
|
2601 |
self sizeChanged:how.
|
|
2602 |
|
|
2603 |
(anyEdge and:[shown]) ifTrue:[
|
|
2604 |
self clipRect:nil.
|
|
2605 |
mustRedrawBottomEdge ifTrue:[
|
|
2606 |
self drawBottomEdge
|
|
2607 |
].
|
|
2608 |
mustRedrawRightEdge ifTrue:[
|
|
2609 |
self drawRightEdge
|
|
2610 |
].
|
|
2611 |
self clipRect:innerClipRect
|
|
2612 |
]
|
|
2613 |
]
|
|
2614 |
!
|
|
2615 |
|
|
2616 |
superViewChangedSize
|
|
2617 |
"my superView has changed size; if I have relative
|
|
2618 |
origin/extent or blocks to evaluate, do it now .."
|
|
2619 |
|
|
2620 |
|oldWidth oldHeight oldTop oldLeft newExt newOrg
|
|
2621 |
winSuper newWidth newHeight newLeft newTop newCorner
|
|
2622 |
superWidth superHeight superWinWidth superWinHeight|
|
|
2623 |
|
|
2624 |
oldWidth := width.
|
|
2625 |
oldHeight := height.
|
|
2626 |
oldTop := top.
|
|
2627 |
oldLeft := left.
|
|
2628 |
|
|
2629 |
viewport notNil ifTrue:[
|
|
2630 |
"
|
|
2631 |
if this view has a viewPort, resize a la st-80
|
|
2632 |
this will vanish - dont use it.
|
|
2633 |
"
|
|
2634 |
superView isNil ifTrue:[^ self].
|
|
2635 |
winSuper := superView window.
|
|
2636 |
winSuper isNil ifTrue:[
|
|
2637 |
"take pixel size as window"
|
|
2638 |
winSuper := 0@0 extent:(superView width@superView height)
|
|
2639 |
].
|
|
2640 |
|
|
2641 |
superWidth := superView width.
|
|
2642 |
superHeight := superView height.
|
|
2643 |
superWinWidth := winSuper width.
|
|
2644 |
superWinHeight := winSuper height.
|
|
2645 |
newLeft := (viewport left - winSuper left) * superWidth // superWinWidth.
|
|
2646 |
newTop := (viewport top - winSuper top) * superHeight // superWinHeight.
|
|
2647 |
newWidth := superWidth * viewport width // superWinWidth.
|
|
2648 |
newHeight := superHeight * viewport height // superWinHeight.
|
|
2649 |
self pixelOrigin:(newLeft @ newTop).
|
|
2650 |
self pixelExtent:(newWidth @ newHeight).
|
|
2651 |
^ self
|
54
|
2652 |
].
|
|
2653 |
|
118
|
2654 |
newOrg := self computeOrigin.
|
|
2655 |
newExt := self computeExtent.
|
|
2656 |
|
|
2657 |
newOrg notNil ifTrue:[
|
|
2658 |
((newOrg x == oldLeft) and:[newOrg y == oldTop]) ifTrue:[
|
|
2659 |
newOrg := nil
|
|
2660 |
]
|
|
2661 |
].
|
|
2662 |
newExt notNil ifTrue:[
|
|
2663 |
((newExt x == width) and:[newExt y == height]) ifTrue:[
|
|
2664 |
newExt := nil
|
|
2665 |
]
|
|
2666 |
].
|
|
2667 |
|
|
2668 |
newExt isNil ifTrue:[
|
|
2669 |
newOrg notNil ifTrue:[
|
|
2670 |
self pixelOrigin:newOrg
|
|
2671 |
]
|
|
2672 |
] ifFalse:[
|
|
2673 |
newOrg isNil ifTrue:[
|
|
2674 |
self pixelExtent:newExt
|
|
2675 |
] ifFalse:[
|
|
2676 |
self pixelOrigin:newOrg extent:newExt
|
|
2677 |
]
|
|
2678 |
]
|
|
2679 |
!
|
|
2680 |
|
|
2681 |
mapped
|
|
2682 |
"the view has been mapped (by some outside
|
|
2683 |
action - i.e. window manager de-iconified me)"
|
|
2684 |
|
54
|
2685 |
"
|
118
|
2686 |
the old code was:
|
|
2687 |
|
|
2688 |
realized := true.
|
|
2689 |
shown := true.
|
|
2690 |
...
|
|
2691 |
|
|
2692 |
this created a race condition, if the view was
|
|
2693 |
realized and shortly after unrealized - before the mapped event
|
|
2694 |
arrived. This lead to shown being set to true even thought the
|
|
2695 |
view was not. Boy - that was a bad one (hard to reproduce and hard to find).
|
54
|
2696 |
"
|
118
|
2697 |
|
|
2698 |
realized ifTrue:[
|
|
2699 |
shown := true.
|
|
2700 |
"
|
|
2701 |
backed views will not get expose events - have
|
|
2702 |
to force a redraw here to get things drawn into
|
|
2703 |
backing store.
|
|
2704 |
"
|
|
2705 |
backed ifTrue:[
|
|
2706 |
self redraw
|
|
2707 |
].
|
|
2708 |
subViews notNil ifTrue:[
|
|
2709 |
subViews do:[:v |
|
|
2710 |
v superViewMapped
|
|
2711 |
]
|
|
2712 |
]
|
0
|
2713 |
]
|
|
2714 |
!
|
|
2715 |
|
|
2716 |
buttonPress:button x:x y:y
|
81
|
2717 |
"button was pressed - if its the middle button
|
|
2718 |
and there is a middleButtonMenu, show it.
|
|
2719 |
If both a model and a menuSelector is is defined, ask the model for
|
|
2720 |
the menu and launch it. The menu is supposed to return an actionSelector
|
|
2721 |
which in turn is sent to the model."
|
|
2722 |
|
|
2723 |
|menu actionSelector|
|
0
|
2724 |
|
82
|
2725 |
components notNil ifTrue:[
|
|
2726 |
components do:[:aComponent |
|
|
2727 |
|thisFrame|
|
|
2728 |
|
|
2729 |
thisFrame := aComponent frame.
|
|
2730 |
(thisFrame containsPointX:x y:y) ifTrue:[
|
|
2731 |
aComponent buttonPress:button x:x - thisFrame left
|
|
2732 |
y:y - thisFrame top.
|
|
2733 |
^ self
|
|
2734 |
]
|
|
2735 |
]
|
|
2736 |
].
|
|
2737 |
|
46
|
2738 |
((button == 2) or:[button == #menu]) ifTrue:[
|
72
|
2739 |
"
|
|
2740 |
try ST-80 style menus first:
|
|
2741 |
if there is a model, and a menuSymbol is defined,
|
|
2742 |
ask model for the menu and launch that if non-nil.
|
|
2743 |
"
|
81
|
2744 |
(model notNil
|
|
2745 |
and:[menuSymbol notNil
|
|
2746 |
and:[menuSymbol isSymbol]]) ifTrue:[
|
|
2747 |
"
|
|
2748 |
ask model for the menu
|
|
2749 |
"
|
72
|
2750 |
menu := model perform:menuSymbol.
|
|
2751 |
menu notNil ifTrue:[
|
81
|
2752 |
"
|
|
2753 |
got one, launch the menu. It is supposed
|
|
2754 |
to return an actionSelector.
|
|
2755 |
"
|
110
|
2756 |
menu receiver isNil ifTrue:[
|
|
2757 |
menu receiver: model
|
|
2758 |
].
|
81
|
2759 |
actionSelector := menu startUp.
|
|
2760 |
(actionSelector notNil
|
|
2761 |
and:[actionSelector isSymbol]) ifTrue:[
|
|
2762 |
model perform:actionSelector
|
72
|
2763 |
]
|
|
2764 |
].
|
|
2765 |
^ self
|
|
2766 |
]
|
0
|
2767 |
].
|
|
2768 |
super buttonPress:button x:x y:y
|
118
|
2769 |
!
|
|
2770 |
|
|
2771 |
unmapped
|
|
2772 |
"the view has been unmapped (by some outside
|
|
2773 |
action - i.e. window manager iconified me)"
|
|
2774 |
|
|
2775 |
shown := false.
|
|
2776 |
subViews notNil ifTrue:[
|
|
2777 |
subViews do:[:v |
|
|
2778 |
v superViewUnmapped
|
|
2779 |
]
|
|
2780 |
]
|
|
2781 |
!
|
|
2782 |
|
|
2783 |
coveredBy:aView
|
|
2784 |
"the receiver has been covered by another view;
|
|
2785 |
we are not interrested in that here (but see modalBox for more)."
|
|
2786 |
!
|
|
2787 |
|
|
2788 |
sizeChanged:how
|
|
2789 |
"tell subviews if I change size.
|
|
2790 |
How is either #smaller, #larger or nil, and is used to control the order,
|
|
2791 |
in which subviews are notified (possibly reducing redraw activity)"
|
|
2792 |
|
|
2793 |
window notNil ifTrue:[
|
|
2794 |
"compute new transformation"
|
|
2795 |
].
|
|
2796 |
subViews notNil ifTrue:[
|
|
2797 |
(how isNil "false"
|
|
2798 |
or:[how == #smaller]) ifTrue:[
|
|
2799 |
subViews do:[:view |
|
|
2800 |
view superViewChangedSize
|
|
2801 |
]
|
|
2802 |
] ifFalse:[
|
|
2803 |
"doing it reverse speeds up resizing - usually subviews
|
|
2804 |
are created from top-left to bottom-right; therefore
|
|
2805 |
bottom-right views will be moved/resized first, then top-left ones;
|
|
2806 |
this avoids multiple redraws of subviews"
|
|
2807 |
|
|
2808 |
subViews reverseDo:[:view |
|
|
2809 |
view superViewChangedSize
|
|
2810 |
]
|
|
2811 |
]
|
|
2812 |
].
|
|
2813 |
self changed:#sizeOfView with:how.
|
|
2814 |
!
|
|
2815 |
|
|
2816 |
superViewUnmapped
|
|
2817 |
"my superView was unmapped"
|
|
2818 |
|
|
2819 |
shown := false.
|
|
2820 |
subViews notNil ifTrue:[
|
|
2821 |
subViews do:[:v |
|
|
2822 |
v superViewUnmapped
|
|
2823 |
]
|
|
2824 |
]
|
|
2825 |
!
|
|
2826 |
|
|
2827 |
reparented
|
|
2828 |
"the view has changed its parent by some outside
|
|
2829 |
action - i.e. window manager has added a frame.
|
|
2830 |
nothing done here"
|
|
2831 |
|
|
2832 |
^ self
|
|
2833 |
!
|
|
2834 |
|
|
2835 |
terminate
|
|
2836 |
"window manager wants me to go away;
|
|
2837 |
- notice, that not all window managers are nice enough to
|
|
2838 |
send this event, but simply destroy the view instead.
|
|
2839 |
Can be redefined in subclasses to do whatever cleanup is
|
|
2840 |
required."
|
|
2841 |
|
|
2842 |
^ self destroy
|
|
2843 |
!
|
|
2844 |
|
|
2845 |
focusIn
|
|
2846 |
"got keyboard focus"
|
|
2847 |
|
|
2848 |
self showFocus
|
|
2849 |
!
|
|
2850 |
|
|
2851 |
keyPress:key x:x y:y
|
129
|
2852 |
"a key has been pressed. If there are components,
|
|
2853 |
pass it to the corresponding one.
|
|
2854 |
Otherwise, forward it to the superview, if there is any."
|
118
|
2855 |
|
|
2856 |
components notNil ifTrue:[
|
|
2857 |
components do:[:aComponent |
|
|
2858 |
|thisFrame|
|
|
2859 |
|
|
2860 |
thisFrame := aComponent frame.
|
|
2861 |
(thisFrame containsPointX:x y:y) ifTrue:[
|
|
2862 |
aComponent keyPress:key x:x - thisFrame left
|
|
2863 |
y:y - thisFrame top.
|
|
2864 |
^ self
|
|
2865 |
]
|
|
2866 |
]
|
|
2867 |
].
|
|
2868 |
|
129
|
2869 |
x >= 0 ifTrue:[
|
|
2870 |
superView notNil ifTrue:[
|
|
2871 |
WindowEvent
|
|
2872 |
sendEvent:#keyPress:x:y:
|
|
2873 |
arguments:(Array with:key with:x with:y)
|
|
2874 |
view:superView
|
|
2875 |
] ifFalse:[
|
|
2876 |
super keyPress:key x:x y:y
|
|
2877 |
]
|
118
|
2878 |
]
|
|
2879 |
!
|
|
2880 |
|
|
2881 |
focusOut
|
|
2882 |
"lost keyboard focus"
|
|
2883 |
|
|
2884 |
self showNoFocus
|
|
2885 |
!
|
|
2886 |
|
|
2887 |
visibilityChange:how
|
|
2888 |
"the visibility of the view has changed (by some outside
|
|
2889 |
action - i.e. window manager rearranged things).
|
|
2890 |
Using this knowledge avoids useless redraw in obsucred views."
|
|
2891 |
|
|
2892 |
how == #fullyObscured ifTrue:[
|
|
2893 |
shown := false
|
|
2894 |
] ifFalse:[
|
|
2895 |
shown := true.
|
|
2896 |
]
|
|
2897 |
!
|
|
2898 |
|
|
2899 |
destroyed
|
|
2900 |
"view has been destroyed by someone else (usually window system)"
|
|
2901 |
|
|
2902 |
shown := false.
|
|
2903 |
super destroyed
|
|
2904 |
!
|
|
2905 |
|
|
2906 |
saveAndTerminate
|
|
2907 |
"window manager wants me to save and go away;
|
|
2908 |
- notice, that not all window managers are nice enough to
|
|
2909 |
send this event, but simply destroy the view instead.
|
|
2910 |
Can be redefined in subclasses to do whatever is required
|
|
2911 |
to prepare for restart."
|
|
2912 |
|
|
2913 |
^ self destroy
|
|
2914 |
! !
|
|
2915 |
|
|
2916 |
!View methodsFor:'accessing-bg & border'!
|
|
2917 |
|
|
2918 |
margin
|
|
2919 |
"return my margin - this is usually the level,
|
|
2920 |
but can be more for some views"
|
|
2921 |
|
|
2922 |
^ margin
|
|
2923 |
!
|
|
2924 |
|
|
2925 |
borderWidth
|
|
2926 |
"return my borderWidth"
|
|
2927 |
|
|
2928 |
^ borderWidth
|
|
2929 |
!
|
|
2930 |
|
|
2931 |
borderWidth:aNumber
|
|
2932 |
"set my borderWidth"
|
|
2933 |
|
|
2934 |
(aNumber ~~ borderWidth) ifTrue:[
|
|
2935 |
borderWidth := aNumber.
|
|
2936 |
drawableId notNil ifTrue:[
|
|
2937 |
device setWindowBorderWidth:aNumber in:drawableId
|
|
2938 |
]
|
|
2939 |
]
|
|
2940 |
!
|
|
2941 |
|
|
2942 |
level:aNumber
|
|
2943 |
"set my level relative to superView (3D)"
|
|
2944 |
|
|
2945 |
|oldMargin how|
|
|
2946 |
|
|
2947 |
(aNumber ~~ level) ifTrue:[
|
|
2948 |
self is3D ifTrue:[
|
|
2949 |
level := aNumber.
|
|
2950 |
oldMargin := margin.
|
|
2951 |
margin := level abs.
|
|
2952 |
|
|
2953 |
realized ifTrue:[
|
|
2954 |
margin ~~ oldMargin ifTrue:[
|
|
2955 |
(margin > oldMargin) ifTrue:[
|
|
2956 |
how := #smaller
|
|
2957 |
] ifFalse:[
|
|
2958 |
how := #larger
|
|
2959 |
].
|
|
2960 |
self sizeChanged:how.
|
|
2961 |
self setInnerClip.
|
|
2962 |
].
|
|
2963 |
shown ifTrue:[
|
|
2964 |
self redrawEdges
|
|
2965 |
]
|
|
2966 |
]
|
|
2967 |
]
|
|
2968 |
]
|
|
2969 |
!
|
|
2970 |
|
|
2971 |
viewBackground:something
|
|
2972 |
"set the viewBackground to something, a color, image or form.
|
|
2973 |
If its a color and we run on a color display, also set shadow and light
|
|
2974 |
colors - this means, that a red view will get light-red and dark-red
|
|
2975 |
edges."
|
|
2976 |
|
|
2977 |
something isColor ifTrue:[
|
|
2978 |
device hasGreyscales ifTrue:[
|
|
2979 |
shadowColor := something darkened.
|
|
2980 |
lightColor := something lightened
|
|
2981 |
]
|
|
2982 |
].
|
|
2983 |
super viewBackground:something
|
|
2984 |
!
|
|
2985 |
|
|
2986 |
heightIncludingBorder
|
|
2987 |
"return my height including border"
|
|
2988 |
|
|
2989 |
^ height + (2*borderWidth)
|
|
2990 |
!
|
|
2991 |
|
|
2992 |
borderColor
|
|
2993 |
"return my borderColor"
|
|
2994 |
|
|
2995 |
^ borderColor
|
|
2996 |
!
|
|
2997 |
|
|
2998 |
borderColor:aColor
|
|
2999 |
"set my borderColor"
|
|
3000 |
|
|
3001 |
(aColor ~~ borderColor) ifTrue:[
|
|
3002 |
borderColor := aColor.
|
|
3003 |
drawableId notNil ifTrue:[
|
|
3004 |
self setBorderColor
|
|
3005 |
]
|
|
3006 |
]
|
|
3007 |
!
|
|
3008 |
|
|
3009 |
borderShape:aForm
|
|
3010 |
"set the borderShape to aForm"
|
|
3011 |
|
|
3012 |
borderShape := aForm.
|
|
3013 |
drawableId notNil ifTrue:[
|
|
3014 |
device setWindowBorderShape:(aForm id) in:drawableId
|
|
3015 |
]
|
|
3016 |
!
|
|
3017 |
|
|
3018 |
viewShape:aForm
|
|
3019 |
"set the viewShape to aForm"
|
|
3020 |
|
|
3021 |
viewShape := aForm.
|
|
3022 |
drawableId notNil ifTrue:[
|
|
3023 |
device setWindowShape:(aForm id) in:drawableId
|
|
3024 |
]
|
|
3025 |
!
|
|
3026 |
|
121
|
3027 |
processName
|
|
3028 |
"return a string to be shown in the process monitor"
|
|
3029 |
|
|
3030 |
^ self name
|
|
3031 |
!
|
|
3032 |
|
118
|
3033 |
name
|
|
3034 |
"return my name component to be used for resource-access"
|
|
3035 |
|
|
3036 |
^ name
|
|
3037 |
!
|
|
3038 |
|
|
3039 |
fullName
|
|
3040 |
"return my full name to be used for resource-access"
|
|
3041 |
|
|
3042 |
superView notNil ifTrue:[
|
|
3043 |
^ superView fullName , '.' , name
|
|
3044 |
].
|
|
3045 |
^ name
|
|
3046 |
!
|
|
3047 |
|
|
3048 |
widthIncludingBorder
|
|
3049 |
"return my width including border"
|
|
3050 |
|
|
3051 |
^ width + (2*borderWidth)
|
|
3052 |
!
|
|
3053 |
|
|
3054 |
name:aString
|
|
3055 |
"set my name component to be used for resource-access"
|
|
3056 |
|
|
3057 |
name := aString
|
|
3058 |
!
|
|
3059 |
|
|
3060 |
level
|
|
3061 |
"return my level relative to superView (3D)"
|
|
3062 |
|
|
3063 |
^ level
|
|
3064 |
!
|
|
3065 |
|
|
3066 |
lightColor:aColorOrImage
|
|
3067 |
"set the color to be used for lighted edges (3D only)"
|
|
3068 |
|
|
3069 |
lightColor := aColorOrImage
|
|
3070 |
!
|
|
3071 |
|
|
3072 |
shadowColor:aColorOrImage
|
|
3073 |
"set the color to be used for shadowed edges (3D only)"
|
|
3074 |
|
|
3075 |
shadowColor := aColorOrImage
|
|
3076 |
! !
|
|
3077 |
|
|
3078 |
!View methodsFor:'drawing'!
|
|
3079 |
|
|
3080 |
drawEdgesForX:x y:y width:w height:h level:l
|
|
3081 |
shadow:shadowColor light:lightColor
|
|
3082 |
halfShadow:halfShadowColor halfLight:halfLightColor
|
|
3083 |
style:edgeStyle
|
|
3084 |
|
|
3085 |
"draw 3D edges into a rectangle"
|
|
3086 |
|
|
3087 |
|topLeftFg botRightFg topLeftHalfFg botRightHalfFg
|
|
3088 |
count "{ Class: SmallInteger }"
|
|
3089 |
r "{ Class: SmallInteger }"
|
|
3090 |
b "{ Class: SmallInteger }"
|
|
3091 |
xi "{ Class: SmallInteger }"
|
|
3092 |
yi "{ Class: SmallInteger }"
|
|
3093 |
run paint|
|
|
3094 |
|
|
3095 |
count := l.
|
|
3096 |
(count < 0) ifTrue:[
|
|
3097 |
topLeftFg := shadowColor.
|
|
3098 |
botRightFg := lightColor.
|
|
3099 |
topLeftHalfFg := halfShadowColor.
|
|
3100 |
botRightHalfFg := halfLightColor.
|
|
3101 |
count := count negated
|
|
3102 |
] ifFalse:[
|
|
3103 |
topLeftFg := lightColor.
|
|
3104 |
botRightFg := shadowColor.
|
|
3105 |
topLeftHalfFg := halfLightColor.
|
|
3106 |
botRightHalfFg := halfShadowColor.
|
|
3107 |
].
|
|
3108 |
topLeftHalfFg isNil ifTrue:[
|
|
3109 |
topLeftHalfFg := topLeftFg
|
|
3110 |
].
|
|
3111 |
botRightHalfFg isNil ifTrue:[
|
|
3112 |
botRightHalfFg := botRightFg
|
|
3113 |
].
|
|
3114 |
|
|
3115 |
r := x + w - 1. "right"
|
|
3116 |
b := y + h - 1. "bottom"
|
|
3117 |
|
|
3118 |
super lineWidth:0.
|
|
3119 |
|
|
3120 |
"top and left edges"
|
|
3121 |
((edgeStyle == #soft) and:[l > 0]) ifTrue:[
|
|
3122 |
paint := topLeftHalfFg
|
|
3123 |
] ifFalse:[
|
|
3124 |
paint := topLeftFg
|
|
3125 |
].
|
|
3126 |
super paint:paint.
|
|
3127 |
|
|
3128 |
0 to:(count - 1) do:[:i |
|
|
3129 |
run := y + i.
|
|
3130 |
super displayDeviceLineFromX:x y:run toX:r y:run. "top"
|
|
3131 |
run := x + i.
|
|
3132 |
super displayDeviceLineFromX:run y:y toX:run y:b "left"
|
|
3133 |
].
|
|
3134 |
(edgeStyle == #soft) ifTrue:[
|
|
3135 |
"
|
|
3136 |
super paint:topLeftFg.
|
|
3137 |
super displayDeviceLineFromX:x y:y toX:r y:y.
|
|
3138 |
super displayDeviceLineFromX:x y:y toX:x y:b
|
|
3139 |
"
|
|
3140 |
(l > 2) ifTrue:[
|
|
3141 |
super paint:Black.
|
|
3142 |
super displayDeviceLineFromX:x y:y toX:r y:y.
|
|
3143 |
super displayDeviceLineFromX:x y:y toX:x y:b.
|
|
3144 |
]
|
|
3145 |
].
|
|
3146 |
|
|
3147 |
xi := x + 1.
|
|
3148 |
yi := y + 1.
|
|
3149 |
|
|
3150 |
"/ does not look good
|
|
3151 |
"/ style == #st80 iftrue:[
|
|
3152 |
"/ yi := yi + 1
|
|
3153 |
"/ ].
|
|
3154 |
|
|
3155 |
"bottom and right edges"
|
|
3156 |
(edgeStyle == #soft) ifTrue:[
|
|
3157 |
paint := botRightHalfFg
|
|
3158 |
] ifFalse:[
|
|
3159 |
paint := botRightFg
|
|
3160 |
].
|
|
3161 |
|
|
3162 |
super paint:paint.
|
|
3163 |
0 to:(count - 1) do:[:i |
|
|
3164 |
run := b - i.
|
|
3165 |
super displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom"
|
|
3166 |
run := r - i.
|
|
3167 |
super displayDeviceLineFromX:run y:yi-1 toX:run y:b. "right"
|
|
3168 |
xi := xi + 1.
|
|
3169 |
yi := yi + 1
|
|
3170 |
].
|
|
3171 |
((edgeStyle == #soft) and:[l > 1]) ifTrue:[
|
|
3172 |
super paint:Black "shadowColor".
|
|
3173 |
super displayDeviceLineFromX:(x + 1-1) y:b toX:r y:b.
|
|
3174 |
super displayDeviceLineFromX:r y:(y + 1 - 1) toX:r y:b
|
|
3175 |
]
|
|
3176 |
!
|
|
3177 |
|
|
3178 |
redrawX:x y:y width:w height:h
|
|
3179 |
"have to redraw part of myself, givel logical coordinates (if trans is nonNil)
|
|
3180 |
default is to redraw everything - subclasses should add intelligence"
|
|
3181 |
|
|
3182 |
|area|
|
|
3183 |
|
|
3184 |
area := Rectangle left:x top:y width:w height:h.
|
|
3185 |
self clippedTo:area do:[
|
|
3186 |
"/ controller notNil ifTrue:[
|
|
3187 |
"/ "ST-80 updating"
|
|
3188 |
"/ self update:#rectangle with:area
|
|
3189 |
"/ ] ifFalse:[
|
|
3190 |
components notNil ifTrue:[
|
|
3191 |
components do:[:aComponent |
|
|
3192 |
|thisFrame is|
|
|
3193 |
|
|
3194 |
thisFrame := aComponent frame.
|
|
3195 |
(thisFrame intersects:area) ifTrue:[
|
|
3196 |
is := thisFrame intersect:(x@y extent:w@h).
|
|
3197 |
is = thisFrame ifTrue:[
|
|
3198 |
aComponent redraw
|
|
3199 |
] ifFalse:[
|
|
3200 |
aComponent redrawX:is left
|
|
3201 |
y:is top
|
|
3202 |
width:is width
|
|
3203 |
height:is height.
|
|
3204 |
].
|
|
3205 |
"/ aComponent drawIn:self offset:0@0
|
|
3206 |
]
|
|
3207 |
]
|
|
3208 |
] ifFalse:[
|
|
3209 |
self redraw
|
|
3210 |
]
|
|
3211 |
"/ ]
|
|
3212 |
]
|
|
3213 |
!
|
|
3214 |
|
|
3215 |
drawBottomEdge
|
|
3216 |
"draw bottom 3D edge into window frame"
|
|
3217 |
|
|
3218 |
self drawBottomEdgeLevel:level
|
|
3219 |
shadow:shadowColor
|
|
3220 |
light:lightColor
|
|
3221 |
halfShadow:nil
|
|
3222 |
halfLight:nil
|
|
3223 |
style:nil.
|
|
3224 |
!
|
|
3225 |
|
|
3226 |
drawEdges
|
|
3227 |
"draw all of my 3D edges"
|
|
3228 |
|
|
3229 |
self drawEdgesForX:0 y:0 width:width height:height level:level
|
|
3230 |
shadow:shadowColor
|
|
3231 |
light:lightColor
|
|
3232 |
halfShadow:nil
|
|
3233 |
halfLight:nil
|
|
3234 |
style:nil
|
|
3235 |
!
|
|
3236 |
|
|
3237 |
redraw
|
|
3238 |
"redraw myself
|
|
3239 |
if there is a model, this one shall redraw itself,
|
|
3240 |
otherwise we cannot do much here - has to be redefined in subclasses"
|
|
3241 |
|
|
3242 |
model notNil ifTrue:[
|
|
3243 |
model update:self
|
|
3244 |
]
|
|
3245 |
!
|
|
3246 |
|
|
3247 |
drawTopEdge
|
|
3248 |
"draw top 3D edge into window frame"
|
|
3249 |
|
|
3250 |
self drawTopEdgeLevel:level
|
|
3251 |
shadow:shadowColor
|
|
3252 |
light:lightColor
|
|
3253 |
halfShadow:nil
|
|
3254 |
halfLight:nil
|
|
3255 |
style:nil.
|
|
3256 |
!
|
|
3257 |
|
|
3258 |
drawLeftEdge
|
|
3259 |
"draw left 3D edge into window frame"
|
|
3260 |
|
|
3261 |
self drawLeftEdgeLevel:level
|
|
3262 |
shadow:shadowColor
|
|
3263 |
light:lightColor
|
|
3264 |
halfShadow:nil
|
|
3265 |
halfLight:nil
|
|
3266 |
style:nil.
|
|
3267 |
!
|
|
3268 |
|
|
3269 |
drawRightEdge
|
|
3270 |
"draw right 3D edge into window frame"
|
|
3271 |
|
|
3272 |
self drawRightEdgeLevel:level
|
|
3273 |
shadow:shadowColor
|
|
3274 |
light:lightColor
|
|
3275 |
halfShadow:nil
|
|
3276 |
halfLight:nil
|
|
3277 |
style:nil.
|
|
3278 |
!
|
|
3279 |
|
|
3280 |
drawRightEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle
|
|
3281 |
|rightFg
|
|
3282 |
count "{ Class: SmallInteger }"
|
|
3283 |
r b|
|
|
3284 |
|
|
3285 |
count := level.
|
|
3286 |
count == 0 ifTrue:[^ self].
|
|
3287 |
|
|
3288 |
(count < 0) ifTrue:[
|
|
3289 |
rightFg := lightColor.
|
|
3290 |
count := count negated
|
|
3291 |
] ifFalse:[
|
|
3292 |
((edgeStyle == #soft) and:[level > 1]) ifTrue:[
|
|
3293 |
rightFg := halfShadowColor
|
|
3294 |
] ifFalse:[
|
|
3295 |
rightFg := shadowColor
|
|
3296 |
].
|
|
3297 |
].
|
|
3298 |
super paint:rightFg.
|
|
3299 |
super lineWidth:0.
|
|
3300 |
|
|
3301 |
b := height - 1.
|
|
3302 |
0 to:(count - 1) do:[:i |
|
|
3303 |
r := width - 1 - i.
|
|
3304 |
super displayDeviceLineFromX:r y:i toX:r y:(b - i)
|
|
3305 |
].
|
|
3306 |
((edgeStyle == #soft) and:[level > 1]) ifTrue:[
|
|
3307 |
r := width - 1.
|
|
3308 |
super paint:shadowColor.
|
|
3309 |
super displayDeviceLineFromX:r y:1 toX:r y:b.
|
|
3310 |
]
|
|
3311 |
!
|
|
3312 |
|
|
3313 |
drawTopEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle
|
|
3314 |
|topFg topHalfFg paint r
|
|
3315 |
count "{ Class: SmallInteger }" |
|
|
3316 |
|
|
3317 |
count := level.
|
|
3318 |
count == 0 ifTrue:[^ self].
|
|
3319 |
|
|
3320 |
(count < 0) ifTrue:[
|
|
3321 |
topFg := shadowColor.
|
|
3322 |
topHalfFg := halfShadowColor.
|
|
3323 |
count := count negated
|
|
3324 |
] ifFalse:[
|
|
3325 |
topFg := lightColor.
|
|
3326 |
topHalfFg := halfLightColor.
|
|
3327 |
].
|
|
3328 |
topHalfFg isNil ifTrue:[
|
|
3329 |
topHalfFg := topFg
|
|
3330 |
].
|
|
3331 |
|
|
3332 |
((edgeStyle == #soft) and:[level > 0]) ifTrue:[
|
|
3333 |
paint := topHalfFg
|
|
3334 |
] ifFalse:[
|
|
3335 |
paint := topFg
|
|
3336 |
].
|
|
3337 |
super paint:paint.
|
|
3338 |
super lineWidth:0.
|
|
3339 |
|
|
3340 |
r := width - 1.
|
|
3341 |
0 to:(count - 1) do:[:i |
|
|
3342 |
super displayDeviceLineFromX:i y:i toX:(r - i) y:i
|
|
3343 |
].
|
|
3344 |
((edgeStyle == #soft) and:[level > 2]) ifTrue:[
|
|
3345 |
super paint:Black.
|
|
3346 |
super displayDeviceLineFromX:0 y:0 toX:r y:0.
|
|
3347 |
]
|
|
3348 |
!
|
|
3349 |
|
|
3350 |
drawBottomEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle
|
|
3351 |
|botFg
|
|
3352 |
count "{ Class: SmallInteger }"
|
|
3353 |
b r|
|
|
3354 |
|
|
3355 |
count := level.
|
|
3356 |
count == 0 ifTrue:[^ self].
|
|
3357 |
|
|
3358 |
(count < 0) ifTrue:[
|
|
3359 |
botFg := lightColor.
|
|
3360 |
count := count negated
|
|
3361 |
] ifFalse:[
|
|
3362 |
((edgeStyle == #soft) and:[level > 1]) ifTrue:[
|
|
3363 |
botFg := halfShadowColor
|
|
3364 |
] ifFalse:[
|
|
3365 |
botFg := shadowColor
|
|
3366 |
].
|
|
3367 |
].
|
|
3368 |
super paint:botFg.
|
|
3369 |
super lineWidth:0.
|
|
3370 |
|
|
3371 |
r := width - 1.
|
|
3372 |
0 to:(count - 1) do:[:i |
|
|
3373 |
b := height - 1 - i.
|
|
3374 |
super displayDeviceLineFromX:i y:b toX:(r - i) y:b
|
|
3375 |
].
|
|
3376 |
|
|
3377 |
((edgeStyle == #soft) and:[level > 1]) ifTrue:[
|
|
3378 |
b := height - 1.
|
|
3379 |
super paint:shadowColor.
|
|
3380 |
super displayDeviceLineFromX:1 y:b toX:r y:b.
|
|
3381 |
]
|
|
3382 |
!
|
|
3383 |
|
|
3384 |
drawLeftEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle
|
|
3385 |
|leftFg leftHalfFg paint b
|
|
3386 |
count "{ Class: SmallInteger }" |
|
|
3387 |
|
|
3388 |
count := level.
|
|
3389 |
count == 0 ifTrue:[^ self].
|
|
3390 |
|
|
3391 |
(count < 0) ifTrue:[
|
|
3392 |
leftFg := shadowColor.
|
|
3393 |
leftHalfFg := halfShadowColor.
|
|
3394 |
count := count negated.
|
|
3395 |
] ifFalse:[
|
|
3396 |
leftFg := lightColor.
|
|
3397 |
leftHalfFg := halfLightColor.
|
|
3398 |
].
|
|
3399 |
leftHalfFg isNil ifTrue:[
|
|
3400 |
leftHalfFg := leftFg
|
|
3401 |
].
|
|
3402 |
|
|
3403 |
((edgeStyle == #soft) and:[level > 0]) ifTrue:[
|
|
3404 |
paint := leftHalfFg
|
|
3405 |
] ifFalse:[
|
|
3406 |
paint := leftFg
|
|
3407 |
].
|
|
3408 |
super paint:paint.
|
|
3409 |
super lineWidth:0.
|
|
3410 |
|
|
3411 |
b := height - 1.
|
|
3412 |
0 to:(count - 1) do:[:i |
|
|
3413 |
super displayDeviceLineFromX:i y:i toX:i y:(b - i)
|
|
3414 |
].
|
|
3415 |
|
|
3416 |
((edgeStyle == #soft) and:[level > 2]) ifTrue:[
|
|
3417 |
super paint:Black.
|
|
3418 |
super displayDeviceLineFromX:0 y:0 toX:0 y:b.
|
|
3419 |
]
|
|
3420 |
!
|
|
3421 |
|
|
3422 |
drawEdgesForX:x y:y width:w height:h level:l
|
|
3423 |
"draw 3D edges into a rectangle"
|
|
3424 |
|
|
3425 |
self drawEdgesForX:x y:y width:w height:h level:l
|
|
3426 |
shadow:shadowColor
|
|
3427 |
light:lightColor
|
|
3428 |
halfShadow:nil
|
|
3429 |
halfLight:nil
|
|
3430 |
style:nil
|
|
3431 |
!
|
|
3432 |
|
|
3433 |
redrawDeviceX:x y:y width:w height:h
|
|
3434 |
"have to redraw part of the view.
|
|
3435 |
The coordinates are in device space - if there is a transformation,
|
|
3436 |
must inverse-transform back to logical coordinates. (since the view thinks
|
|
3437 |
in its coordinate space)"
|
|
3438 |
|
|
3439 |
|lx ly lw lh|
|
|
3440 |
|
|
3441 |
lx := x.
|
|
3442 |
ly := y.
|
|
3443 |
lw := w.
|
|
3444 |
lh := h.
|
|
3445 |
|
|
3446 |
transformation notNil ifTrue:[
|
|
3447 |
lx := transformation applyInverseToX:lx.
|
|
3448 |
ly := transformation applyInverseToY:ly.
|
|
3449 |
lw := transformation applyInverseScaleX:lw.
|
|
3450 |
lh := transformation applyInverseScaleY:lh.
|
|
3451 |
].
|
|
3452 |
self redrawX:lx y:ly width:lw height:lh
|
|
3453 |
!
|
|
3454 |
|
|
3455 |
redrawEdges
|
|
3456 |
"redraw my edges (if any)"
|
|
3457 |
|
|
3458 |
(level ~~ 0) ifTrue:[
|
|
3459 |
self clipRect:nil.
|
|
3460 |
self drawEdges.
|
|
3461 |
self clipRect:innerClipRect
|
|
3462 |
]
|
|
3463 |
!
|
|
3464 |
|
|
3465 |
showFocus
|
|
3466 |
"highlight myself somehow to tell user that I have the focus"
|
|
3467 |
|
|
3468 |
|delta|
|
|
3469 |
|
|
3470 |
drawableId notNil ifTrue:[
|
|
3471 |
delta := DefaultFocusBorderWidth - borderWidth.
|
|
3472 |
delta ~~ 0 ifTrue:[
|
|
3473 |
device moveWindow:drawableId x:left-delta y:top-delta
|
|
3474 |
].
|
|
3475 |
device setWindowBorderWidth:DefaultFocusBorderWidth in:drawableId.
|
|
3476 |
device setWindowBorderColor:(DefaultFocusColor on:device) colorId in:drawableId.
|
|
3477 |
]
|
|
3478 |
!
|
|
3479 |
|
|
3480 |
showNoFocus
|
|
3481 |
"undo the effect of showFocus"
|
|
3482 |
|
|
3483 |
|delta|
|
|
3484 |
|
|
3485 |
drawableId notNil ifTrue:[
|
|
3486 |
delta := DefaultFocusBorderWidth - borderWidth.
|
|
3487 |
delta ~~ 0 ifTrue:[
|
|
3488 |
device moveWindow:drawableId x:left+delta y:top+delta
|
|
3489 |
].
|
|
3490 |
device setWindowBorderWidth:borderWidth in:drawableId.
|
|
3491 |
self setBorderColor.
|
|
3492 |
]
|
|
3493 |
! !
|
|
3494 |
|
|
3495 |
!View methodsFor:'realization'!
|
|
3496 |
|
|
3497 |
initializeMiddleButtonMenu
|
|
3498 |
"a place to initialize menu - this one is sent once when the view is
|
|
3499 |
first created; usually redefined in subclasses; default here is no menu"
|
|
3500 |
|
|
3501 |
^ self
|
|
3502 |
!
|
|
3503 |
|
|
3504 |
fixSize
|
|
3505 |
"This is called right before the view is made visible.
|
|
3506 |
Adjust the size of the view according to either relative/abs or
|
|
3507 |
block extent; also set origin. Also, subclasses may redefine this
|
|
3508 |
method to adjust the size based on some extent (for example, PopUpMenus
|
|
3509 |
do so to take care of changed number of menu entries)."
|
|
3510 |
|
|
3511 |
|org|
|
|
3512 |
|
|
3513 |
window notNil ifTrue:[
|
|
3514 |
^ self superViewChangedSize
|
|
3515 |
].
|
|
3516 |
|
|
3517 |
"if the extent is not the one we created the window with ..."
|
|
3518 |
extentChanged ifTrue:[
|
|
3519 |
self sizeChanged:nil.
|
|
3520 |
extentChanged := false
|
|
3521 |
].
|
|
3522 |
|
|
3523 |
originChanged ifTrue:[
|
|
3524 |
"/ org := self computeOrigin.
|
|
3525 |
"/ self pixelOrigin:org.
|
|
3526 |
originRule notNil ifTrue:[
|
|
3527 |
self pixelOrigin:(originRule value)
|
|
3528 |
] ifFalse:[
|
|
3529 |
relativeOrigin notNil ifTrue:[
|
|
3530 |
self originFromRelativeOrigin
|
|
3531 |
] ifFalse:[
|
|
3532 |
device moveWindow:drawableId x:left y:top.
|
|
3533 |
].
|
|
3534 |
].
|
|
3535 |
originChanged := false
|
|
3536 |
]
|
|
3537 |
!
|
|
3538 |
|
|
3539 |
realizeLeavingGroup:leaveGroupAsIs
|
|
3540 |
"common helper for realize and realizeInGroup"
|
|
3541 |
|
|
3542 |
|superGroup groupChange|
|
|
3543 |
|
|
3544 |
drawableId isNil ifTrue:[
|
|
3545 |
self create.
|
|
3546 |
].
|
|
3547 |
|
|
3548 |
leaveGroupAsIs ifFalse:[
|
|
3549 |
"
|
|
3550 |
put myself into superviews windowgroup if there is a superview
|
|
3551 |
"
|
|
3552 |
groupChange := false.
|
|
3553 |
superView notNil ifTrue:[
|
|
3554 |
superGroup := superView windowGroup.
|
|
3555 |
(windowGroup notNil and:[superGroup ~~ windowGroup]) ifTrue:[
|
|
3556 |
"
|
|
3557 |
mhmh - seems that the windowgroup has changed ....
|
|
3558 |
"
|
|
3559 |
"/ 'oops - wgroup change on realize' printNewline.
|
|
3560 |
windowGroup removeView:self.
|
|
3561 |
windowGroup := nil
|
|
3562 |
].
|
|
3563 |
superGroup ~~ windowGroup ifTrue:[
|
|
3564 |
groupChange := true.
|
|
3565 |
windowGroup := superGroup.
|
|
3566 |
windowGroup notNil ifTrue:[
|
|
3567 |
windowGroup addView:self.
|
|
3568 |
]
|
|
3569 |
]
|
|
3570 |
].
|
|
3571 |
].
|
|
3572 |
|
|
3573 |
hidden ifFalse:[
|
|
3574 |
(originChanged or:[extentChanged]) ifTrue:[self fixSize].
|
|
3575 |
|
|
3576 |
(realized not or:[groupChange]) ifTrue:[
|
|
3577 |
subViews notNil ifTrue:[
|
|
3578 |
subViews do:[:subView |
|
|
3579 |
subView realize
|
|
3580 |
]
|
|
3581 |
].
|
|
3582 |
].
|
|
3583 |
self setInnerClip.
|
|
3584 |
|
|
3585 |
realized ifFalse:[
|
|
3586 |
"
|
|
3587 |
now, make the view visible
|
|
3588 |
"
|
|
3589 |
device mapWindow:drawableId.
|
|
3590 |
realized := true
|
|
3591 |
]
|
|
3592 |
].
|
|
3593 |
|
|
3594 |
controller notNil ifTrue:[
|
|
3595 |
controller startUp
|
|
3596 |
]
|
|
3597 |
!
|
|
3598 |
|
|
3599 |
physicalCreate
|
|
3600 |
"common code for create & recreate"
|
|
3601 |
|
|
3602 |
"associate colors to device"
|
|
3603 |
|
|
3604 |
drawableId := device
|
|
3605 |
createWindowFor:self
|
|
3606 |
origin:(left @ top)
|
|
3607 |
extent:(width @ height)
|
|
3608 |
minExtent:nil
|
|
3609 |
maxExtent:nil
|
|
3610 |
borderWidth:borderWidth
|
|
3611 |
subViewOf:superView
|
|
3612 |
onTop:(self createOnTop)
|
|
3613 |
inputOnly:(self inputOnly)
|
|
3614 |
label:nil
|
|
3615 |
cursor:cursor
|
|
3616 |
icon:nil
|
|
3617 |
iconView:nil.
|
|
3618 |
|
|
3619 |
Lobby changed:self.
|
|
3620 |
extentChanged := false.
|
|
3621 |
originChanged := false.
|
|
3622 |
|
|
3623 |
(borderColor notNil and:[borderColor ~~ Black]) ifTrue:[
|
|
3624 |
"/ borderColor := borderColor on:device.
|
|
3625 |
self setBorderColor
|
|
3626 |
].
|
|
3627 |
(viewGravity notNil "and:[viewGravity ~~ #NorthWest]") ifTrue:[
|
|
3628 |
device setWindowGravity:viewGravity in:drawableId
|
|
3629 |
].
|
|
3630 |
(bitGravity notNil "and:[bitGravity ~~ #NorthWest]") ifTrue:[
|
|
3631 |
device setBitGravity:bitGravity in:drawableId
|
|
3632 |
].
|
|
3633 |
borderShape notNil ifTrue:[
|
|
3634 |
device setWindowBorderShape:(borderShape id) in:drawableId
|
|
3635 |
].
|
|
3636 |
viewShape notNil ifTrue:[
|
|
3637 |
device setWindowShape:(viewShape id) in:drawableId
|
|
3638 |
].
|
|
3639 |
(backed notNil and:[backed ~~ false]) ifTrue:[
|
|
3640 |
device setBackingStore:backed in:drawableId
|
|
3641 |
].
|
|
3642 |
saveUnder ifTrue:[
|
|
3643 |
device setSaveUnder:true in:drawableId
|
|
3644 |
].
|
|
3645 |
!
|
|
3646 |
|
|
3647 |
unrealize
|
|
3648 |
"hide me"
|
|
3649 |
|
|
3650 |
realized ifTrue:[
|
|
3651 |
drawableId notNil ifTrue:[
|
|
3652 |
device unmapWindow:drawableId
|
|
3653 |
].
|
|
3654 |
realized := shown := false.
|
|
3655 |
]
|
|
3656 |
!
|
|
3657 |
|
|
3658 |
realize
|
|
3659 |
"realize - make visible;
|
|
3660 |
realizing is done very late (after layout is fixed) to avoid
|
|
3661 |
visible rearranging of windows on the screen"
|
|
3662 |
|
|
3663 |
self realizeLeavingGroup:false
|
|
3664 |
!
|
|
3665 |
|
|
3666 |
create
|
|
3667 |
"create (i.e. tell X about me)
|
|
3668 |
this is kind of stupid - creation means XCreateWindow;
|
|
3669 |
realizing means XMapWindow"
|
|
3670 |
|
|
3671 |
drawableId isNil ifTrue:[
|
|
3672 |
"
|
|
3673 |
make certain that superview is created also
|
|
3674 |
"
|
|
3675 |
superView notNil ifTrue:[
|
|
3676 |
"/ superView id isNil ifTrue:[
|
|
3677 |
superView create.
|
|
3678 |
"/ ].
|
|
3679 |
|
|
3680 |
"/ "and put my controller into the superviews controller list"
|
|
3681 |
"/ controller notNil ifTrue:[
|
|
3682 |
"/ superView controller notNil ifTrue:[
|
|
3683 |
"/ controller manager:(superView controller manager)
|
|
3684 |
"/ ]
|
|
3685 |
"/ ]
|
|
3686 |
].
|
|
3687 |
|
|
3688 |
cursor := cursor on:device.
|
|
3689 |
|
|
3690 |
self physicalCreate.
|
|
3691 |
|
|
3692 |
viewBackground notNil ifTrue:[
|
|
3693 |
self setViewBackground
|
|
3694 |
].
|
|
3695 |
|
|
3696 |
self initializeMiddleButtonMenu.
|
|
3697 |
self initEvents.
|
|
3698 |
|
|
3699 |
"
|
|
3700 |
this is the first create,
|
|
3701 |
force sizechange messages to be sent to the view
|
|
3702 |
"
|
|
3703 |
extentChanged := true.
|
|
3704 |
originChanged := true
|
|
3705 |
]
|
|
3706 |
!
|
|
3707 |
|
|
3708 |
open
|
|
3709 |
"open up the view - for normal views, this is a modeless open
|
|
3710 |
(i.e. the new view comes up as independent process).
|
|
3711 |
This is redefined in ModalBox, which comes up modal (i.e.
|
|
3712 |
control is under the current process, so that interaction with the
|
|
3713 |
current group is blocked while the modalBox is active)."
|
|
3714 |
|
|
3715 |
^ self openModeless
|
|
3716 |
!
|
|
3717 |
|
|
3718 |
openModeless
|
|
3719 |
"create and schedule a new windowgroup for me and open the view.
|
|
3720 |
The view will be handled by its own process, effectively running in
|
|
3721 |
parallel."
|
|
3722 |
|
|
3723 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
3724 |
windowGroup isNil ifTrue:[
|
|
3725 |
windowGroup := WindowGroup new.
|
|
3726 |
windowGroup addTopView:self.
|
|
3727 |
].
|
|
3728 |
windowGroup startup.
|
|
3729 |
] ifTrue:[
|
|
3730 |
self realize
|
|
3731 |
]
|
|
3732 |
!
|
|
3733 |
|
|
3734 |
openModal
|
|
3735 |
"create a new windowgroup, but start processing in the current process
|
|
3736 |
actually suspending event processing for the currently active group.
|
|
3737 |
Stay in modalLoop while view is visible."
|
|
3738 |
|
|
3739 |
self openModal:[true]
|
|
3740 |
!
|
|
3741 |
|
|
3742 |
recreate
|
|
3743 |
"recreate (i.e. tell X about me) after a snapin"
|
|
3744 |
|
|
3745 |
drawableId isNil ifTrue:[
|
|
3746 |
super recreate.
|
|
3747 |
self physicalCreate.
|
|
3748 |
|
|
3749 |
viewBackground notNil ifTrue:[
|
|
3750 |
self setViewBackground
|
|
3751 |
].
|
|
3752 |
|
|
3753 |
"
|
|
3754 |
XXX has to be changed: eventmasks are device specific -
|
|
3755 |
XXX will not allow restart on another Workstation-type.
|
|
3756 |
XXX event masks must become symbolic
|
|
3757 |
"
|
|
3758 |
device setEventMask:eventMask in:drawableId
|
|
3759 |
]
|
|
3760 |
!
|
|
3761 |
|
|
3762 |
createWithAllSubViews
|
|
3763 |
"create, then create all subviews"
|
|
3764 |
|
|
3765 |
drawableId isNil ifTrue:[self create].
|
|
3766 |
subViews notNil ifTrue:[
|
|
3767 |
subViews do:[:subView | subView createWithAllSubViews]
|
|
3768 |
]
|
|
3769 |
!
|
|
3770 |
|
|
3771 |
destroy
|
|
3772 |
"unrealize & destroy - make me invisible, destroy subviews then
|
|
3773 |
make me unknown to the device"
|
|
3774 |
|
|
3775 |
|subs|
|
|
3776 |
|
|
3777 |
realized ifTrue:[
|
|
3778 |
self unrealize.
|
|
3779 |
"make it go away immediately
|
|
3780 |
- also, this hides the subview killing"
|
|
3781 |
"
|
|
3782 |
device synchronizeOutput.
|
|
3783 |
"
|
|
3784 |
].
|
|
3785 |
|
|
3786 |
model notNil ifTrue:[
|
|
3787 |
model removeDependent:self.
|
|
3788 |
model := nil.
|
|
3789 |
].
|
|
3790 |
controller notNil ifTrue:[
|
|
3791 |
controller release.
|
|
3792 |
controller := nil.
|
|
3793 |
].
|
|
3794 |
|
|
3795 |
subs := subViews.
|
|
3796 |
subs notNil ifTrue:[
|
|
3797 |
"stupid: destroy removes itself from the subview list
|
|
3798 |
- therefore we have to loop over a copy here"
|
|
3799 |
|
|
3800 |
subViews := nil.
|
|
3801 |
subs do:[:aView |
|
|
3802 |
aView notNil ifTrue:[aView destroy]
|
|
3803 |
]
|
|
3804 |
].
|
|
3805 |
superView notNil ifTrue:[
|
|
3806 |
superView removeSubView:self.
|
|
3807 |
superView := nil
|
|
3808 |
].
|
|
3809 |
super destroy.
|
|
3810 |
|
|
3811 |
windowGroup notNil ifTrue:[
|
|
3812 |
windowGroup removeView:self.
|
|
3813 |
windowGroup := nil
|
|
3814 |
].
|
|
3815 |
!
|
|
3816 |
|
|
3817 |
realizeInGroup
|
|
3818 |
"special realize - leave windowgroup as is;
|
|
3819 |
This allows a view to be realized in any windowgroup;
|
|
3820 |
for special applications, like the kill button in the Filebrowser which has
|
|
3821 |
another windowGroup as its superview and is handled as a separate process."
|
|
3822 |
|
|
3823 |
self realizeLeavingGroup:true
|
|
3824 |
!
|
|
3825 |
|
|
3826 |
openModal:aBlock
|
|
3827 |
"create a new windowgroup, but start processing in the current process -
|
|
3828 |
actually suspending event processing for the currently active group.
|
|
3829 |
Stay in this modal loop while aBlock evaluates to true AND the receiver is
|
|
3830 |
visible.
|
|
3831 |
This makes any interaction with the current window impossible -
|
|
3832 |
however, other views (in other windowgroups) still work."
|
|
3833 |
|
|
3834 |
|activeGroup tops|
|
|
3835 |
|
|
3836 |
Processor activeProcessIsSystemProcess ifTrue:[
|
|
3837 |
self realize
|
|
3838 |
] ifFalse:[
|
|
3839 |
activeGroup := WindowGroup activeGroup.
|
|
3840 |
|
|
3841 |
"
|
|
3842 |
create a new window group and put myself into it
|
|
3843 |
"
|
|
3844 |
windowGroup := WindowGroup new.
|
|
3845 |
windowGroup addTopView:self.
|
|
3846 |
"
|
|
3847 |
go dispatch events in this new group
|
|
3848 |
(thus current windowgroup is blocked from interaction)
|
|
3849 |
"
|
|
3850 |
Object abortSignal handle:[:ex |
|
|
3851 |
self hide.
|
|
3852 |
ex return.
|
|
3853 |
] do:[
|
|
3854 |
[
|
|
3855 |
windowGroup startupModal:[realized and:aBlock]
|
|
3856 |
] valueOnUnwindDo:[
|
|
3857 |
self hide.
|
|
3858 |
]
|
|
3859 |
].
|
|
3860 |
"
|
|
3861 |
return input focus to previously active groups top.
|
|
3862 |
This helps with windowmanagers which need an explicit click
|
|
3863 |
on the view for the focus.
|
|
3864 |
"
|
|
3865 |
activeGroup notNil ifTrue:[
|
|
3866 |
tops := activeGroup topViews.
|
|
3867 |
(tops notNil and:[tops notEmpty]) ifTrue:[
|
|
3868 |
tops first getKeyboardFocus
|
|
3869 |
]
|
|
3870 |
]
|
|
3871 |
]
|
|
3872 |
!
|
|
3873 |
|
123
|
3874 |
rerealizeWithAllSubViews
|
|
3875 |
"rerealize myself with all subviews"
|
118
|
3876 |
|
|
3877 |
drawableId notNil ifTrue:[
|
|
3878 |
realized := true.
|
|
3879 |
subViews notNil ifTrue:[
|
|
3880 |
subViews do:[:aView |
|
|
3881 |
aView realize
|
|
3882 |
]
|
|
3883 |
].
|
|
3884 |
device mapView:self id:drawableId iconified:false
|
|
3885 |
atX:left y:top width:width height:height
|
|
3886 |
]
|
|
3887 |
!
|
|
3888 |
|
123
|
3889 |
rerealize
|
|
3890 |
"rerealize at old position"
|
|
3891 |
|
|
3892 |
drawableId notNil ifTrue:[
|
|
3893 |
realized := true.
|
|
3894 |
device mapView:self id:drawableId iconified:false
|
|
3895 |
atX:left y:top width:width height:height
|
|
3896 |
]
|
|
3897 |
!
|
|
3898 |
|
118
|
3899 |
openAutonomous
|
|
3900 |
"create and schedule a new windowgroup for me and open the view.
|
|
3901 |
The view will be handled by its own process, effectively running in
|
|
3902 |
parallel. This entry is for non-topviews, which want to be served
|
|
3903 |
autonomous from the topview. (see the fileBrowsers kill-button
|
|
3904 |
when executing unix commands as an example)"
|
|
3905 |
|
|
3906 |
|wg|
|
|
3907 |
|
|
3908 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
3909 |
wg := WindowGroup new.
|
|
3910 |
self windowGroup:wg.
|
|
3911 |
wg addView:self.
|
|
3912 |
wg startup.
|
|
3913 |
self realizeInGroup.
|
|
3914 |
] ifTrue:[
|
|
3915 |
self realize
|
|
3916 |
]
|
|
3917 |
! !
|
|
3918 |
|
|
3919 |
!View methodsFor:'adding & removing components'!
|
|
3920 |
|
|
3921 |
setParentViewIn:aView
|
|
3922 |
"common code for addSubView* methods"
|
|
3923 |
|
|
3924 |
aView superView:self.
|
|
3925 |
(aView device ~~ device) ifTrue:[
|
|
3926 |
'warning subview (' errorPrint. aView class name errorPrint.
|
|
3927 |
') has different device than me (' errorPrint.
|
|
3928 |
self class name errorPrint. ').' errorPrintNewline.
|
|
3929 |
aView device:device
|
|
3930 |
]
|
|
3931 |
!
|
|
3932 |
|
|
3933 |
addSubView:newView
|
|
3934 |
"add a view to the collection of subviews"
|
|
3935 |
|
|
3936 |
subViews isNil ifTrue:[
|
|
3937 |
subViews := OrderedCollection with:newView
|
|
3938 |
] ifFalse:[
|
|
3939 |
subViews add:newView.
|
|
3940 |
].
|
|
3941 |
self setParentViewIn:newView.
|
|
3942 |
!
|
|
3943 |
|
|
3944 |
removeSubView:aView
|
|
3945 |
"remove a view from the collection of subviews"
|
|
3946 |
|
|
3947 |
subViews notNil ifTrue:[
|
|
3948 |
subViews remove:aView ifAbsent:[nil].
|
|
3949 |
(subViews size == 0) ifTrue:[
|
|
3950 |
subViews := nil
|
|
3951 |
]
|
|
3952 |
]
|
|
3953 |
!
|
|
3954 |
|
|
3955 |
addComponent:aComponent
|
|
3956 |
"components (i.e. gadgets or lightweight views) are being prepared.
|
|
3957 |
Dont use this right now"
|
|
3958 |
|
|
3959 |
components isNil ifTrue:[
|
|
3960 |
components := OrderedCollection new
|
|
3961 |
].
|
|
3962 |
components add:aComponent.
|
|
3963 |
aComponent setParentViewIn:self
|
|
3964 |
!
|
|
3965 |
|
|
3966 |
component:aComponent
|
|
3967 |
"components (i.e. gadgets or lightweight views) are being prepared.
|
|
3968 |
Dont use this right now"
|
|
3969 |
|
|
3970 |
components := OrderedCollection with:aComponent.
|
|
3971 |
aComponent setParentViewIn:self
|
|
3972 |
!
|
|
3973 |
|
|
3974 |
removeComponent:aComponent
|
|
3975 |
"components (i.e. gadgets or lightweight views) are being prepared.
|
|
3976 |
Dont use this right now"
|
|
3977 |
|
|
3978 |
components isNil ifTrue:[^self].
|
|
3979 |
components remove:aComponent ifAbsent:[].
|
|
3980 |
aComponent parent:nil
|
|
3981 |
!
|
|
3982 |
|
|
3983 |
addSubView:newView after:aView
|
|
3984 |
"add a view to the collection of subviews after another view.
|
|
3985 |
This makes sense, in Panels and other layout views, to enter a new
|
|
3986 |
element at some defined place."
|
|
3987 |
|
|
3988 |
subViews isNil ifTrue:[
|
|
3989 |
subViews := OrderedCollection with:newView
|
|
3990 |
] ifFalse:[
|
|
3991 |
subViews add:newView after:aView.
|
|
3992 |
].
|
|
3993 |
self setParentViewIn:newView.
|
|
3994 |
!
|
|
3995 |
|
|
3996 |
addSubView:newView before:aView
|
|
3997 |
"add a view to the collection of subviews before another view.
|
|
3998 |
This makes sense, in Panels and other layout views, to enter a new
|
|
3999 |
element at some defined place."
|
|
4000 |
|
|
4001 |
subViews isNil ifTrue:[
|
|
4002 |
subViews := OrderedCollection with:newView
|
|
4003 |
] ifFalse:[
|
|
4004 |
subViews add:newView before:aView.
|
|
4005 |
].
|
|
4006 |
self setParentViewIn:newView.
|
|
4007 |
!
|
|
4008 |
|
|
4009 |
addSubView:aView in:bounds borderWidth:bw
|
|
4010 |
"for ST-80 compatibility"
|
|
4011 |
|
|
4012 |
aView borderWidth:bw.
|
|
4013 |
aView origin:(bounds origin x asFloat) @ (bounds origin y asFloat)
|
|
4014 |
extent:(bounds extent x asFloat) @ (bounds extent y asFloat).
|
|
4015 |
self addSubView:aView
|
|
4016 |
!
|
|
4017 |
|
|
4018 |
add:aView in:bounds
|
|
4019 |
"for ST-80 compatibility"
|
|
4020 |
|
|
4021 |
aView origin:(bounds origin x asFloat) @ (bounds origin y asFloat)
|
|
4022 |
extent:(bounds extent x asFloat) @ (bounds extent y asFloat).
|
|
4023 |
self addSubView:aView
|
|
4024 |
!
|
|
4025 |
|
|
4026 |
addSubView:aView viewport:aRectangle
|
|
4027 |
"Adds aView to the views list of subviews and uses the
|
|
4028 |
existing subviews window and the new viewport to position it"
|
|
4029 |
|
|
4030 |
self addSubView:aView.
|
|
4031 |
aView viewport:aRectangle
|
|
4032 |
!
|
|
4033 |
|
|
4034 |
addSubView:aView window:aWindowRectangle viewport:aViewportRectangle
|
|
4035 |
"Adds aView to the views list of subviews and uses
|
|
4036 |
aWindowRectangle and aViewportRectangle to position it"
|
|
4037 |
|
|
4038 |
self addSubView:aView.
|
|
4039 |
aView window:aWindowRectangle.
|
|
4040 |
aView viewport:aViewportRectangle
|
|
4041 |
! !
|
|
4042 |
|
|
4043 |
!View methodsFor:'queries'!
|
|
4044 |
|
|
4045 |
canHandle:aKey
|
|
4046 |
"return true, if I like to handle the key (keyPress event)"
|
|
4047 |
|
|
4048 |
^ true
|
|
4049 |
!
|
|
4050 |
|
|
4051 |
buttonMotionEventPending
|
|
4052 |
"return true, if a button motion event is pending.
|
|
4053 |
Normally, you dont want to use this, since no polling is needed
|
|
4054 |
(not even for mouse-tracking).
|
|
4055 |
Dont use it, since it does not honor the windowGroup, but
|
|
4056 |
goes directly to the device instead.
|
|
4057 |
Actually, its a historical leftover"
|
|
4058 |
|
|
4059 |
windowGroup notNil ifTrue:[
|
|
4060 |
^ windowGroup sensor hasButtonMotionEventsFor:self
|
|
4061 |
].
|
|
4062 |
^ super buttonMotionEventPending
|
|
4063 |
!
|
|
4064 |
|
|
4065 |
preferedExtent
|
|
4066 |
"return my preferred extent - this is the minimum size I would like to have.
|
|
4067 |
The default here is the actual extent, the receiver currently has."
|
|
4068 |
|
|
4069 |
^ self extent
|
|
4070 |
! !
|
|
4071 |
|
|
4072 |
!View methodsFor:'enumerating subviews'!
|
|
4073 |
|
|
4074 |
allSubViewsDo:aBlock
|
|
4075 |
"evaluate aBlock for all subviews (recursively)"
|
|
4076 |
|
|
4077 |
(subViews isNil or:[subViews isEmpty]) ifFalse:[
|
|
4078 |
subViews do:[:aSubview |
|
|
4079 |
aSubview withAllSubViewsDo:aBlock
|
|
4080 |
]
|
|
4081 |
]
|
|
4082 |
!
|
|
4083 |
|
|
4084 |
withAllSubViewsDo:aBlock
|
|
4085 |
"evaluate aBlock for the receiver and all subviews (recursively)"
|
|
4086 |
|
|
4087 |
aBlock value:self.
|
|
4088 |
self allSubViewsDo:aBlock
|
|
4089 |
! !
|
|
4090 |
|
|
4091 |
!View methodsFor:'scrolling-basic'!
|
|
4092 |
|
|
4093 |
scrollUp:nPixels
|
|
4094 |
"change origin to scroll up (towards the origin) by some pixels"
|
|
4095 |
|
|
4096 |
|count "{ Class:SmallInteger }"
|
|
4097 |
m2 "{ Class:SmallInteger }"
|
|
4098 |
w "{ Class:SmallInteger }"
|
|
4099 |
h "{ Class:SmallInteger }"
|
|
4100 |
orgX
|
|
4101 |
orgY "{ Class:SmallInteger }"
|
|
4102 |
newOrigin|
|
|
4103 |
|
|
4104 |
transformation isNil ifTrue:[
|
|
4105 |
orgY := orgX := 0
|
|
4106 |
] ifFalse:[
|
|
4107 |
orgY := transformation translation y negated.
|
|
4108 |
orgX := transformation translation x negated
|
|
4109 |
].
|
|
4110 |
|
|
4111 |
count := nPixels.
|
|
4112 |
(count > orgY) ifTrue:[
|
|
4113 |
count := orgY
|
|
4114 |
].
|
|
4115 |
(count <= 0) ifTrue:[^ self].
|
|
4116 |
|
|
4117 |
self originWillChange.
|
|
4118 |
newOrigin := orgX @ (orgY - count).
|
|
4119 |
|
|
4120 |
shown ifFalse:[
|
|
4121 |
self setViewOrigin:newOrigin.
|
|
4122 |
] ifTrue:[
|
|
4123 |
m2 := margin * 2. "top & bottom margins"
|
|
4124 |
(count >= self innerHeight) ifTrue:[
|
|
4125 |
self setViewOrigin:newOrigin.
|
|
4126 |
self redrawDeviceX:margin y:margin
|
|
4127 |
width:(width - m2)
|
|
4128 |
height:(height - m2).
|
|
4129 |
] ifFalse:[
|
|
4130 |
h := height - m2 - count.
|
|
4131 |
w := width.
|
|
4132 |
self catchExpose.
|
|
4133 |
self setViewOrigin:newOrigin.
|
|
4134 |
self copyFrom:self x:margin y:margin
|
|
4135 |
toX:margin y:(count + margin)
|
|
4136 |
width:w height:h.
|
|
4137 |
|
|
4138 |
self setInnerClip.
|
|
4139 |
self redrawDeviceX:margin y:margin
|
|
4140 |
width:(width - m2)
|
|
4141 |
height:count.
|
|
4142 |
|
|
4143 |
self waitForExpose.
|
|
4144 |
]
|
|
4145 |
].
|
|
4146 |
self originChanged:(0 @ count negated).
|
|
4147 |
!
|
|
4148 |
|
|
4149 |
scrollDown:nPixels
|
|
4150 |
"change origin to scroll down some pixels"
|
|
4151 |
|
|
4152 |
|count "{ Class:SmallInteger }"
|
|
4153 |
m2 "{ Class:SmallInteger }"
|
|
4154 |
w "{ Class:SmallInteger }"
|
|
4155 |
h "{ Class:SmallInteger }"
|
|
4156 |
hCont
|
|
4157 |
ih "{ Class:SmallInteger }"
|
|
4158 |
orgX
|
|
4159 |
orgY "{ Class:SmallInteger }"
|
|
4160 |
newOrigin|
|
|
4161 |
|
|
4162 |
hCont := self heightOfContents.
|
|
4163 |
transformation isNil ifTrue:[
|
|
4164 |
orgY := orgX := 0
|
|
4165 |
] ifFalse:[
|
|
4166 |
hCont := (transformation applyScaleY:hCont) rounded.
|
|
4167 |
orgY := transformation translation y negated.
|
|
4168 |
orgX := transformation translation x negated.
|
|
4169 |
].
|
|
4170 |
|
|
4171 |
count := nPixels.
|
|
4172 |
ih := self innerHeight.
|
|
4173 |
|
|
4174 |
((orgY + nPixels + ih) > hCont) ifTrue:[
|
|
4175 |
count := hCont - orgY - ih
|
|
4176 |
].
|
|
4177 |
(count <= 0) ifTrue:[^ self].
|
|
4178 |
|
|
4179 |
self originWillChange.
|
|
4180 |
newOrigin := orgX @ (orgY + count).
|
|
4181 |
shown ifFalse:[
|
|
4182 |
self setViewOrigin:newOrigin.
|
|
4183 |
] ifTrue:[
|
|
4184 |
m2 := margin * 2.
|
|
4185 |
(count >= ih) ifTrue:[
|
|
4186 |
self setViewOrigin:newOrigin.
|
|
4187 |
self redrawDeviceX:margin y:margin
|
|
4188 |
width:(width - m2)
|
|
4189 |
height:(height - m2).
|
|
4190 |
] ifFalse:[
|
|
4191 |
h := height - m2 - count.
|
|
4192 |
w := self width.
|
|
4193 |
self catchExpose.
|
|
4194 |
self setViewOrigin:newOrigin.
|
|
4195 |
self copyFrom:self x:margin y:(count + margin)
|
|
4196 |
toX:margin y:margin
|
|
4197 |
width:w
|
|
4198 |
height:h.
|
|
4199 |
|
|
4200 |
self setInnerClip.
|
|
4201 |
self redrawDeviceX:margin y:(h + margin)
|
|
4202 |
width:(width - m2) height:count.
|
|
4203 |
|
|
4204 |
self waitForExpose.
|
|
4205 |
]
|
|
4206 |
].
|
|
4207 |
self originChanged:(0 @ count).
|
|
4208 |
!
|
|
4209 |
|
|
4210 |
scrollLeft:nPixels
|
|
4211 |
"change origin to scroll left some pixels"
|
|
4212 |
|
|
4213 |
|count "{ Class:SmallInteger }"
|
|
4214 |
m2 "{ Class:SmallInteger }"
|
|
4215 |
h "{ Class:SmallInteger }"
|
|
4216 |
orgX orgY newOrigin|
|
|
4217 |
|
|
4218 |
transformation isNil ifTrue:[
|
|
4219 |
orgY := orgX := 0
|
|
4220 |
] ifFalse:[
|
|
4221 |
orgY := transformation translation y negated.
|
|
4222 |
orgX := transformation translation x negated.
|
|
4223 |
].
|
|
4224 |
|
|
4225 |
count := nPixels.
|
|
4226 |
(count > orgX) ifTrue:[
|
|
4227 |
count := orgX
|
|
4228 |
].
|
|
4229 |
(count <= 0) ifTrue:[^ self].
|
|
4230 |
|
|
4231 |
self originWillChange.
|
|
4232 |
newOrigin := (orgX - count) @ orgY.
|
|
4233 |
|
|
4234 |
shown ifFalse:[
|
|
4235 |
self setViewOrigin:newOrigin.
|
|
4236 |
] ifTrue:[
|
|
4237 |
m2 := margin * 2.
|
|
4238 |
(count >= self innerWidth) ifTrue:[
|
|
4239 |
self setViewOrigin:newOrigin.
|
|
4240 |
self redrawDeviceX:margin y:margin
|
|
4241 |
width:(width - m2)
|
|
4242 |
height:(height - m2).
|
|
4243 |
] ifFalse:[
|
|
4244 |
h := (height - m2).
|
|
4245 |
|
|
4246 |
self catchExpose.
|
|
4247 |
self setViewOrigin:newOrigin.
|
|
4248 |
self copyFrom:self x:margin y:margin
|
|
4249 |
toX:(count + margin) y:margin
|
|
4250 |
width:(width - m2 - count)
|
|
4251 |
height:h.
|
|
4252 |
|
|
4253 |
self setInnerClip.
|
|
4254 |
self redrawDeviceX:margin y:margin
|
|
4255 |
width:count height:(height - m2).
|
|
4256 |
|
|
4257 |
self waitForExpose.
|
|
4258 |
]
|
|
4259 |
].
|
|
4260 |
self originChanged:(count negated @ 0).
|
|
4261 |
!
|
|
4262 |
|
|
4263 |
scrollRight:nPixels
|
|
4264 |
"change origin to scroll right some pixels"
|
|
4265 |
|
|
4266 |
|count "{ Class:SmallInteger }"
|
|
4267 |
m2 "{ Class:SmallInteger }"
|
|
4268 |
h "{ Class:SmallInteger }"
|
|
4269 |
wCont
|
|
4270 |
iw "{ Class:SmallInteger }"
|
|
4271 |
orgX orgY newOrigin|
|
|
4272 |
|
|
4273 |
wCont := self widthOfContents.
|
|
4274 |
transformation isNil ifTrue:[
|
|
4275 |
orgY := orgX := 0
|
|
4276 |
] ifFalse:[
|
|
4277 |
wCont := (transformation applyScaleX:wCont) rounded.
|
|
4278 |
orgY := transformation translation y negated.
|
|
4279 |
orgX := transformation translation x negated.
|
|
4280 |
].
|
|
4281 |
|
|
4282 |
count := nPixels.
|
|
4283 |
iw := self innerWidth.
|
|
4284 |
|
|
4285 |
((orgX + nPixels + iw) > wCont) ifTrue:[
|
|
4286 |
count := wCont - orgX - iw
|
|
4287 |
].
|
|
4288 |
(count <= 0) ifTrue:[^ self].
|
|
4289 |
|
|
4290 |
self originWillChange.
|
|
4291 |
newOrigin := (orgX + count) @ orgY.
|
|
4292 |
|
|
4293 |
shown ifFalse:[
|
|
4294 |
self setViewOrigin:newOrigin.
|
|
4295 |
] ifTrue:[
|
|
4296 |
m2 := margin * 2.
|
|
4297 |
(count >= iw) ifTrue:[
|
|
4298 |
self setViewOrigin:newOrigin.
|
|
4299 |
self redrawDeviceX:margin y:margin
|
|
4300 |
width:(width - m2)
|
|
4301 |
height:(height - m2).
|
|
4302 |
] ifFalse:[
|
|
4303 |
m2 := margin * 2.
|
|
4304 |
h := (height - m2).
|
|
4305 |
|
|
4306 |
self catchExpose.
|
|
4307 |
self setViewOrigin:newOrigin.
|
|
4308 |
self copyFrom:self x:(count + margin) y:margin
|
|
4309 |
toX:margin y:margin
|
|
4310 |
width:(width - m2 - count)
|
|
4311 |
height:h.
|
|
4312 |
|
|
4313 |
self setInnerClip.
|
|
4314 |
self redrawDeviceX:(width - margin - count) y:margin
|
|
4315 |
width:count height:(height - m2).
|
|
4316 |
|
|
4317 |
self waitForExpose.
|
|
4318 |
].
|
|
4319 |
].
|
|
4320 |
self originChanged:(count @ 0).
|
|
4321 |
! !
|
|
4322 |
|
|
4323 |
!View methodsFor:'scrolling'!
|
|
4324 |
|
|
4325 |
widthForScrollBetween:yStart and:yEnd
|
|
4326 |
"return the width in pixels for a scroll between yStart and yEnd
|
|
4327 |
- return full width here since we do not know how wide contents is.
|
|
4328 |
Views which only use part of their space (short lists, text) may redefine
|
|
4329 |
this method and return the number of pixels that have to be scrolled.
|
|
4330 |
On slow displays, this may make a difference; on fast ones you will probably
|
|
4331 |
not notice any difference."
|
|
4332 |
|
|
4333 |
^ (width - margin - margin)
|
|
4334 |
!
|
|
4335 |
|
|
4336 |
verticalScrollStep
|
|
4337 |
"return the amount to scroll when stepping up/down.
|
|
4338 |
Subclasses may want to redefine this."
|
|
4339 |
|
|
4340 |
^ (device verticalPixelPerMillimeter * 20) asInteger
|
|
4341 |
!
|
|
4342 |
|
|
4343 |
scrollVerticalToPercent:percent
|
|
4344 |
"scroll to a position given in percent of total"
|
|
4345 |
|
|
4346 |
|hCont|
|
|
4347 |
|
|
4348 |
hCont := self heightOfContents.
|
|
4349 |
transformation notNil ifTrue:[
|
|
4350 |
hCont := transformation applyScaleY:hCont.
|
|
4351 |
].
|
|
4352 |
self scrollVerticalTo:
|
|
4353 |
((((hCont * percent) / 100.0) + 0.5) asInteger)
|
|
4354 |
!
|
|
4355 |
|
|
4356 |
scrollVerticalTo:aPixelOffset
|
|
4357 |
"change origin to make aPixelOffset be the top line"
|
|
4358 |
|
|
4359 |
|orgY|
|
|
4360 |
|
|
4361 |
orgY := self viewOrigin y.
|
|
4362 |
|
|
4363 |
(aPixelOffset < orgY) ifTrue:[
|
|
4364 |
self scrollUp:(orgY - aPixelOffset)
|
|
4365 |
] ifFalse:[
|
|
4366 |
(aPixelOffset > orgY) ifTrue:[
|
|
4367 |
self scrollDown:(aPixelOffset - orgY)
|
|
4368 |
]
|
|
4369 |
]
|
|
4370 |
!
|
|
4371 |
|
|
4372 |
horizontalScrollStep
|
|
4373 |
"return the amount to scroll when stepping left/right.
|
|
4374 |
Subclasses may want to redefine this."
|
|
4375 |
|
|
4376 |
^ (device horizontalPixelPerMillimeter * 20) asInteger
|
|
4377 |
!
|
|
4378 |
|
|
4379 |
scrollHorizontalToPercent:percent
|
|
4380 |
"scroll to a position given in percent of total"
|
|
4381 |
|
|
4382 |
|wCont|
|
|
4383 |
|
|
4384 |
wCont := self widthOfContents.
|
|
4385 |
transformation notNil ifTrue:[
|
|
4386 |
wCont := transformation applyScaleX:wCont.
|
|
4387 |
].
|
|
4388 |
self scrollHorizontalTo:
|
|
4389 |
((((wCont * percent) / 100.0) + 0.5) asInteger)
|
|
4390 |
!
|
|
4391 |
|
|
4392 |
scrollHorizontalTo:aPixelOffset
|
|
4393 |
"change origin to make aPixelOffset be the left col"
|
|
4394 |
|
|
4395 |
|orgX|
|
|
4396 |
|
|
4397 |
orgX := self viewOrigin x.
|
|
4398 |
|
|
4399 |
(aPixelOffset < orgX) ifTrue:[
|
|
4400 |
self scrollLeft:(orgX - aPixelOffset)
|
|
4401 |
] ifFalse:[
|
|
4402 |
(aPixelOffset > orgX) ifTrue:[
|
|
4403 |
self scrollRight:(aPixelOffset - orgX)
|
|
4404 |
]
|
|
4405 |
]
|
|
4406 |
!
|
|
4407 |
|
|
4408 |
scrollTo:aPixelOffset
|
|
4409 |
"only here for historic reasons - will vanish soon"
|
|
4410 |
|
|
4411 |
^ self scrollVerticalTo:aPixelOffset
|
|
4412 |
!
|
|
4413 |
|
|
4414 |
scrollToTop
|
|
4415 |
"move viewOrigin to top"
|
|
4416 |
|
|
4417 |
self scrollVerticalTo:0
|
|
4418 |
!
|
|
4419 |
|
|
4420 |
scrollToTopLeft
|
|
4421 |
"move viewOrigin to top/left"
|
|
4422 |
|
|
4423 |
self scrollVerticalTo:0.
|
|
4424 |
self scrollHorizontalTo:0
|
|
4425 |
!
|
|
4426 |
|
|
4427 |
scrollUp
|
|
4428 |
"scroll up by some amount; this is called when the scrollbars
|
|
4429 |
scroll-step up button is pressed."
|
|
4430 |
|
|
4431 |
self scrollUp:(self verticalScrollStep)
|
|
4432 |
!
|
|
4433 |
|
|
4434 |
scrollDown
|
|
4435 |
"scroll down by some amount; this is called when the scrollbars
|
|
4436 |
scroll-step down button is pressed."
|
|
4437 |
|
|
4438 |
self scrollDown:(self verticalScrollStep)
|
|
4439 |
!
|
|
4440 |
|
|
4441 |
scrollLeft
|
|
4442 |
"scroll left by some amount; this is called when the scrollbars
|
|
4443 |
scroll-step left button is pressed."
|
|
4444 |
|
|
4445 |
self scrollLeft:(self horizontalScrollStep)
|
|
4446 |
!
|
|
4447 |
|
|
4448 |
scrollRight
|
|
4449 |
"scroll right by some amount; this is called when the scrollbars
|
|
4450 |
scroll-step right button is pressed."
|
|
4451 |
|
|
4452 |
self scrollRight:(self horizontalScrollStep)
|
|
4453 |
! !
|
|
4454 |
|
|
4455 |
!View methodsFor:'user notification'!
|
|
4456 |
|
|
4457 |
warn:aString
|
|
4458 |
"like Objects warn, but translates the string via the
|
|
4459 |
resourcePack, thus giving a translated string automatically"
|
|
4460 |
|
|
4461 |
super warn:(resources string:aString)
|
|
4462 |
!
|
|
4463 |
|
|
4464 |
warn:aString with:argument
|
|
4465 |
"like Objects warn, but translates the string via the
|
|
4466 |
resourcePack, thus giving a translated string automatically"
|
|
4467 |
|
|
4468 |
super warn:(resources string:aString with:argument)
|
0
|
4469 |
! !
|
36
|
4470 |
|
|
4471 |
!View methodsFor:'cursor animation'!
|
|
4472 |
|
|
4473 |
showBusyWhile:aBlock
|
|
4474 |
"evaluate some time consuming block, while doing this,
|
|
4475 |
show a spinning wheel cursor"
|
|
4476 |
|
|
4477 |
|ok bitmaps cursors mask process oldCursor|
|
|
4478 |
|
|
4479 |
oldCursor := cursor.
|
81
|
4480 |
|
|
4481 |
ok := true.
|
|
4482 |
bitmaps := #('wheel1' 'wheel2' 'wheel3' 'wheel4')
|
|
4483 |
collect:[:name |
|
|
4484 |
|f|
|
|
4485 |
|
|
4486 |
f := Form fromFile:(name , '.xbm').
|
|
4487 |
f isNil ifTrue:[
|
|
4488 |
('no bitmap file: ' , name , '.xbm') errorPrintNL.
|
|
4489 |
ok := false
|
|
4490 |
].
|
|
4491 |
f
|
|
4492 |
].
|
|
4493 |
|
|
4494 |
mask := Form fromFile:'wheelm.xbm'.
|
|
4495 |
mask isNil ifTrue:[
|
|
4496 |
('no bitmap file: ' , mask , '.xbm') errorPrintNL.
|
|
4497 |
ok := false
|
41
|
4498 |
].
|
36
|
4499 |
|
|
4500 |
ok ifFalse:[
|
72
|
4501 |
self cursor:Cursor wait.
|
|
4502 |
aBlock valueNowOrOnUnwindDo:[
|
|
4503 |
self cursor:oldCursor
|
|
4504 |
]
|
36
|
4505 |
] ifTrue:[
|
72
|
4506 |
cursors := bitmaps collect:[:form | (Cursor sourceForm:form
|
|
4507 |
maskForm:mask
|
|
4508 |
hotX:8
|
|
4509 |
hotY:8) on:device].
|
|
4510 |
|
|
4511 |
process := [
|
|
4512 |
(Delay forSeconds:0.25) wait.
|
|
4513 |
[true] whileTrue:[
|
|
4514 |
cursors do:[:curs |
|
|
4515 |
self cursor:curs.
|
|
4516 |
(Delay forSeconds:0.05) wait
|
|
4517 |
]
|
|
4518 |
]
|
|
4519 |
] fork.
|
|
4520 |
|
|
4521 |
Processor activeProcess priority:7.
|
|
4522 |
aBlock valueNowOrOnUnwindDo:[
|
|
4523 |
Processor activeProcess priority:8.
|
|
4524 |
process terminate.
|
|
4525 |
self cursor:oldCursor
|
|
4526 |
]
|
36
|
4527 |
].
|
41
|
4528 |
|
81
|
4529 |
"
|
|
4530 |
View new realize showBusyWhile:[10 timesRepeat:[3000 factorial]]
|
|
4531 |
"
|
36
|
4532 |
! !
|
118
|
4533 |
|
|
4534 |
View initialize!
|