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