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