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