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