0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
PseudoView subclass:#View
|
|
14 |
instanceVariableNames:'superView subViews
|
|
15 |
components style resources
|
|
16 |
transformation viewport
|
|
17 |
borderColor borderWidth borderShape viewShape
|
|
18 |
top left
|
|
19 |
extentChanged originChanged cornerChanged
|
|
20 |
relativeOrigin relativeExtent relativeCorner
|
|
21 |
originRule extentRule cornerRule
|
|
22 |
topInset leftInset bottomInset rightInset
|
|
23 |
shown hidden name
|
|
24 |
level softEdge margin innerClipRect
|
|
25 |
shadowColor lightColor
|
|
26 |
halfShadowColor halfLightColor
|
|
27 |
viewOrigin
|
|
28 |
contentsChangeAction originChangeAction
|
|
29 |
bitGravity viewGravity
|
12
|
30 |
keyboardHandler model controller windowGroup
|
0
|
31 |
aspectSymbol changeSymbol menuSymbol'
|
|
32 |
classVariableNames: 'Grey ZeroPoint CentPoint
|
2
|
33 |
ViewSpacing DefaultStyle'
|
0
|
34 |
poolDictionaries: ''
|
|
35 |
category:'Views-Basic'
|
|
36 |
!
|
|
37 |
|
2
|
38 |
View class instanceVariableNames:'ClassResources'!
|
|
39 |
|
0
|
40 |
View comment:'
|
|
41 |
|
6
|
42 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
43 |
All Rights Reserved
|
|
44 |
|
20
|
45 |
$Header: /cvs/stx/stx/libview/View.st,v 1.7 1993-12-19 23:42:23 claus Exp $
|
2
|
46 |
|
|
47 |
written spring/summer 89 by claus
|
|
48 |
3D effects summer 90 by claus
|
|
49 |
MVC, viewport and window stuff summer 92 by claus (for ST-80 compatibility)
|
|
50 |
'!
|
|
51 |
|
|
52 |
"this flag controls (globally) how views look"
|
|
53 |
|
|
54 |
Smalltalk at:#View3D put:false!
|
|
55 |
|
|
56 |
!View class methodsFor:'documentation'!
|
|
57 |
"
|
|
58 |
this class implements functions common to all Views.
|
|
59 |
Instances of View are seldom used, most views in the system inherit from this class.
|
|
60 |
However, sometimes a view is used to create a dummy view for framing purposes.
|
0
|
61 |
|
|
62 |
Instance variables:
|
|
63 |
|
|
64 |
superView <aView> my superview i.e. the view I am in
|
|
65 |
subViews <aCollection> the collection of subviews
|
|
66 |
transformation <WindowingTransformation>
|
|
67 |
window <Rectangle> my window i.e. local coordinate-system
|
|
68 |
viewport <Rectangle> my Rectangle in superviews coordinates
|
|
69 |
borderColor <Color> color of border
|
|
70 |
borderWidth <Number> borderWidth in pixels (device dep.)
|
|
71 |
borderShape <Form> shape of border (if device supports it)
|
|
72 |
viewShape <Form> shape of view (if device supports it)
|
|
73 |
top <Number> top coordinate in superview
|
|
74 |
left <Number> left coordinate in superview
|
|
75 |
extendChanged <Boolean> true if extend changed during setup
|
|
76 |
originChanged <Boolean> true if origin changed during setup
|
|
77 |
relativeOrigin <Number> relative origin in percent within superview
|
|
78 |
relativeExtent <Number> relative extent in percent within superview
|
|
79 |
originRule <Block> rule to compute origin if superview changes size
|
|
80 |
extentRule <Block> rule to compute extent if superview changes size
|
|
81 |
shown <Boolean> true if visible (false if iconified)
|
|
82 |
hidden <Boolean> dont show automatically when superview is realized
|
|
83 |
name <String> my name (future use for resources)
|
|
84 |
level <Number> 3D level relative to superview
|
|
85 |
margin <Number> convenient margin
|
|
86 |
innerClipRect <Rectangle> convenient inner clip (minus margin)
|
|
87 |
shadowColor <Color> color used to draw 3D shadowed edges
|
|
88 |
lightColor <Color> color used to draw 3D lighted edges
|
|
89 |
viewOrigin <Point> origin within model
|
|
90 |
contentsChanngeAction <Block> action to perform when model contents changes
|
|
91 |
originChangeAction <Block> action to perform when model origin changes
|
|
92 |
bitGravity <Symbol> gravity of contents (if device supports it)
|
|
93 |
viewGravity <Symbol> gravity of view (if device supports it)
|
|
94 |
keyboardHandler <anObject> gets keyboard input if non-nil
|
12
|
95 |
model <anObject> the model (if any)
|
|
96 |
controller <aController> the controller
|
0
|
97 |
|
|
98 |
Class variables:
|
|
99 |
|
|
100 |
Grey <Color> the color grey - its used so often
|
|
101 |
ViewSpacing <Number> the number of pixels in a millimeter (prefered
|
|
102 |
spacing between views)
|
|
103 |
ZeroPoint <Point> 0 @ 0 - its used so often
|
|
104 |
CentPoint <Point> 100 @ 100 - its used so often
|
2
|
105 |
"
|
|
106 |
! !
|
0
|
107 |
|
|
108 |
!View class methodsFor:'initialization'!
|
|
109 |
|
|
110 |
initialize
|
|
111 |
"Workstation initialize."
|
|
112 |
|
|
113 |
super initialize.
|
|
114 |
Form initialize.
|
|
115 |
Color initialize.
|
|
116 |
! !
|
|
117 |
|
|
118 |
!View class methodsFor:'defaults'!
|
|
119 |
|
|
120 |
defaultExtent
|
|
121 |
"define the default extent"
|
|
122 |
|
|
123 |
CentPoint isNil ifTrue:[CentPoint := 100 @ 100].
|
|
124 |
^ CentPoint
|
|
125 |
!
|
|
126 |
|
|
127 |
defaultStyle
|
12
|
128 |
"return the default view style"
|
|
129 |
|
0
|
130 |
^ DefaultStyle
|
|
131 |
|
|
132 |
"View defaultStyle"
|
|
133 |
!
|
|
134 |
|
|
135 |
defaultStyle:aStyle
|
12
|
136 |
"set the default view style"
|
|
137 |
|
0
|
138 |
DefaultStyle := aStyle
|
|
139 |
|
|
140 |
"View defaultStyle:#next"
|
2
|
141 |
!
|
|
142 |
|
|
143 |
classResources
|
12
|
144 |
"if not already loaded, get the classes resourcePack
|
|
145 |
and return it"
|
|
146 |
|
2
|
147 |
ClassResources isNil ifTrue:[
|
|
148 |
ClassResources := ResourcePack for:self.
|
|
149 |
].
|
|
150 |
^ ClassResources
|
0
|
151 |
! !
|
|
152 |
|
|
153 |
!View class methodsFor:'instance creation'!
|
|
154 |
|
|
155 |
in:aView
|
|
156 |
"return a new view as a subview of aView"
|
|
157 |
|
|
158 |
|newView|
|
|
159 |
|
|
160 |
newView := self basicNew.
|
|
161 |
newView device:(aView device).
|
|
162 |
newView superView:(aView).
|
|
163 |
newView initialize.
|
|
164 |
aView addSubView:newView.
|
|
165 |
^ newView
|
|
166 |
!
|
|
167 |
|
|
168 |
extent:extent in:aView
|
|
169 |
"create a new view as a subview of aView with given extent"
|
|
170 |
|
|
171 |
^ self origin:nil extent:extent borderWidth:nil
|
|
172 |
font:nil label:nil in:aView
|
|
173 |
!
|
|
174 |
|
|
175 |
origin:origin in:aView
|
|
176 |
"create a new view as a subview of aView with given origin"
|
|
177 |
|
|
178 |
^ self origin:origin extent:nil borderWidth:nil
|
|
179 |
font:nil label:nil in:aView
|
|
180 |
!
|
|
181 |
|
|
182 |
extent:extent
|
|
183 |
"create a new view with given extent"
|
|
184 |
|
|
185 |
^ self origin:nil extent:extent borderWidth:nil
|
|
186 |
font:nil label:nil in:nil
|
|
187 |
!
|
|
188 |
|
|
189 |
origin:origin extent:extent
|
|
190 |
"create a new view with given origin and extent"
|
|
191 |
|
|
192 |
^ self origin:origin extent:extent borderWidth:nil
|
|
193 |
font:nil label:nil in:nil
|
|
194 |
!
|
|
195 |
|
|
196 |
origin:origin extent:extent in:aView
|
|
197 |
"create a new view as a subview of aView with given origin and extent"
|
|
198 |
|
|
199 |
^ self origin:origin extent:extent borderWidth:nil
|
|
200 |
font:nil label:nil in:aView
|
|
201 |
!
|
|
202 |
|
|
203 |
origin:origin extent:extent borderWidth:bw in:aView
|
|
204 |
"create a new view as a subview of aView with given origin, extent
|
|
205 |
and borderWidth"
|
|
206 |
|
|
207 |
^ self origin:origin extent:extent borderWidth:bw
|
|
208 |
font:nil label:nil in:aView
|
|
209 |
!
|
|
210 |
|
|
211 |
origin:origin extent:extent borderWidth:bw
|
|
212 |
"create a new view with given origin, extent and borderWidth"
|
|
213 |
|
|
214 |
^ self origin:origin extent:extent borderWidth:bw
|
|
215 |
font:nil label:nil in:nil
|
|
216 |
!
|
|
217 |
|
|
218 |
label:label
|
|
219 |
"create a new view with given label"
|
|
220 |
|
|
221 |
^ self origin:nil extent:nil borderWidth:nil
|
|
222 |
font:nil label:label in:nil
|
|
223 |
!
|
|
224 |
|
|
225 |
label:label in:aView
|
|
226 |
"create a new view as subview of aView with given label"
|
|
227 |
|
|
228 |
^ self origin:nil extent:nil borderWidth:nil
|
|
229 |
font:nil label:label in:aView
|
|
230 |
!
|
|
231 |
|
|
232 |
extent:extent label:label
|
|
233 |
"create a new view with given extent and label"
|
|
234 |
|
|
235 |
^ self origin:nil extent:extent borderWidth:nil
|
|
236 |
font:nil label:label in:nil
|
|
237 |
!
|
|
238 |
|
|
239 |
origin:origin extent:extent label:label
|
|
240 |
"create a new view with given origin, extent and label"
|
|
241 |
|
|
242 |
^ self origin:origin extent:extent borderWidth:nil
|
|
243 |
font:nil label:label in:nil
|
|
244 |
!
|
|
245 |
|
|
246 |
origin:origin extent:extent font:aFont label:label
|
|
247 |
^ self origin:origin extent:extent borderWidth:nil
|
|
248 |
font:nil label:label in:nil
|
|
249 |
!
|
|
250 |
|
|
251 |
origin:origin extent:extent font:aFont label:label in:aView
|
|
252 |
^ self origin:origin extent:extent borderWidth:nil
|
|
253 |
font:aFont label:label in:aView
|
|
254 |
!
|
|
255 |
|
|
256 |
origin:anOrigin extent:anExtent
|
|
257 |
label:aLabel icon:aForm
|
|
258 |
minExtent:minExtent maxExtent:maxExtent
|
|
259 |
|newView|
|
|
260 |
|
|
261 |
newView := self on:Display.
|
|
262 |
anOrigin notNil ifTrue:[newView origin:anOrigin].
|
|
263 |
anExtent notNil ifTrue:[newView extent:anExtent].
|
|
264 |
aLabel notNil ifTrue:[newView label:aLabel].
|
|
265 |
aForm notNil ifTrue:[newView icon:aForm].
|
|
266 |
minExtent notNil ifTrue:[newView minExtent:minExtent].
|
|
267 |
maxExtent notNil ifTrue:[newView maxExtent:maxExtent].
|
|
268 |
^ newView
|
|
269 |
!
|
|
270 |
|
|
271 |
origin:anOrigin extent:anExtent borderWidth:bw
|
|
272 |
font:aFont label:aLabel in:aView
|
|
273 |
|newView|
|
|
274 |
|
|
275 |
aView notNil ifTrue:[
|
|
276 |
newView := self basicNew.
|
|
277 |
newView device:(aView device).
|
|
278 |
aView addSubView:newView.
|
|
279 |
newView initialize
|
|
280 |
] ifFalse:[
|
|
281 |
newView := self on:Display
|
|
282 |
].
|
|
283 |
bw notNil ifTrue:[newView borderWidth:bw].
|
|
284 |
anExtent notNil ifTrue:[newView extent:anExtent].
|
|
285 |
anOrigin notNil ifTrue:[newView origin:anOrigin].
|
|
286 |
aFont notNil ifTrue:[newView font:aFont].
|
|
287 |
aLabel notNil ifTrue:[newView label:aLabel].
|
|
288 |
^ newView
|
|
289 |
!
|
|
290 |
|
|
291 |
origin:origin corner:corner
|
|
292 |
"create a new view with given origin and extent"
|
|
293 |
|
|
294 |
^ self origin:origin corner:corner borderWidth:nil
|
|
295 |
font:nil label:nil in:nil
|
|
296 |
!
|
|
297 |
|
|
298 |
origin:origin corner:corner in:aView
|
|
299 |
"create a new view as a subview of aView with given origin and extent"
|
|
300 |
|
|
301 |
^ self origin:origin corner:corner borderWidth:nil
|
|
302 |
font:nil label:nil in:aView
|
|
303 |
!
|
|
304 |
|
|
305 |
origin:origin corner:corner borderWidth:bw in:aView
|
|
306 |
"create a new view as a subview of aView with given origin and extent"
|
|
307 |
|
|
308 |
^ self origin:origin corner:corner borderWidth:bw
|
|
309 |
font:nil label:nil in:aView
|
|
310 |
!
|
|
311 |
|
|
312 |
origin:anOrigin corner:aCorner borderWidth:bw
|
|
313 |
font:aFont label:aLabel in:aView
|
|
314 |
|newView|
|
|
315 |
|
|
316 |
aView notNil ifTrue:[
|
|
317 |
newView := self basicNew.
|
|
318 |
newView device:(aView device).
|
|
319 |
aView addSubView:newView.
|
|
320 |
newView initialize
|
|
321 |
] ifFalse:[
|
|
322 |
newView := self on:Display
|
|
323 |
].
|
|
324 |
bw notNil ifTrue:[newView borderWidth:bw].
|
|
325 |
anOrigin notNil ifTrue:[newView origin:anOrigin].
|
|
326 |
aCorner notNil ifTrue:[newView corner:aCorner].
|
|
327 |
aFont notNil ifTrue:[newView font:aFont].
|
|
328 |
aLabel notNil ifTrue:[newView label:aLabel].
|
|
329 |
^ newView
|
|
330 |
!
|
|
331 |
|
|
332 |
on:anObject aspect:aspectMsg change:changeMsg menu:menuMsg
|
|
333 |
^ self new on:anObject
|
|
334 |
aspect:aspectMsg
|
|
335 |
change:changeMsg
|
|
336 |
menu:menuMsg
|
|
337 |
!
|
|
338 |
|
|
339 |
model:aModel
|
|
340 |
^ self new model:aModel
|
|
341 |
! !
|
|
342 |
|
|
343 |
!View methodsFor:'initialization'!
|
|
344 |
|
|
345 |
initialize
|
12
|
346 |
"initialize all state of the view - usually redefined in subclasses,
|
|
347 |
but always doing a 'super initialize'. Each class should setup its
|
|
348 |
locals - and not forget the others.
|
|
349 |
View setup is separated into two parts, the general setup done here
|
|
350 |
and the style specific setup in initStyle. Each view should be prepared
|
|
351 |
for a style change by beeing sent another initStyle with a new style value"
|
|
352 |
|
0
|
353 |
|ext|
|
|
354 |
|
|
355 |
super initialize.
|
|
356 |
shown := false.
|
12
|
357 |
hidden := false.
|
|
358 |
realized := false.
|
0
|
359 |
|
|
360 |
"fill in some defaults - some of them are usually redefined in subclasses
|
|
361 |
initialize methods"
|
|
362 |
|
|
363 |
name := self class name.
|
|
364 |
ext := self class defaultExtent.
|
|
365 |
|
|
366 |
level := 0.
|
|
367 |
margin := 0.
|
|
368 |
softEdge := false.
|
|
369 |
|
2
|
370 |
resources := self class classResources.
|
|
371 |
|
0
|
372 |
self initStyle.
|
|
373 |
|
|
374 |
left := 0.
|
|
375 |
top := 0.
|
|
376 |
width := ext x.
|
|
377 |
height := ext y.
|
|
378 |
ZeroPoint isNil ifTrue:[ZeroPoint := 0 @ 0].
|
|
379 |
viewOrigin := ZeroPoint.
|
|
380 |
ViewSpacing isNil ifTrue:[
|
|
381 |
ViewSpacing := Display verticalPixelPerMillimeter rounded
|
|
382 |
].
|
|
383 |
originChanged := false.
|
|
384 |
extentChanged := false.
|
|
385 |
bitGravity := nil.
|
|
386 |
viewGravity := nil.
|
|
387 |
|
12
|
388 |
"
|
|
389 |
controller := self defaultController new.
|
|
390 |
controller view:self.
|
|
391 |
"
|
|
392 |
!
|
|
393 |
|
|
394 |
defaultController
|
|
395 |
^ Controller
|
0
|
396 |
!
|
|
397 |
|
|
398 |
initStyle
|
12
|
399 |
"this method sets up all style dependent things"
|
|
400 |
|
2
|
401 |
Grey isNil ifTrue:[
|
|
402 |
Grey := resources name:'VIEW_GREY' default:nil.
|
|
403 |
Grey isNil ifTrue:[
|
|
404 |
Grey := Color grey
|
|
405 |
].
|
|
406 |
].
|
|
407 |
DefaultStyle isNil ifTrue:[
|
|
408 |
DefaultStyle := resources name:'VIEW_STYLE'
|
|
409 |
default:(View3D ifTrue:[#view3D]
|
|
410 |
ifFalse:[#normal])
|
|
411 |
].
|
|
412 |
|
0
|
413 |
style := DefaultStyle.
|
|
414 |
|
|
415 |
self is3D ifTrue:[
|
|
416 |
borderWidth := 0
|
|
417 |
] ifFalse:[
|
|
418 |
borderWidth := 1
|
|
419 |
].
|
|
420 |
|
|
421 |
(self is3D and:[device hasGreyscales]) ifTrue:[
|
|
422 |
viewBackground := Grey.
|
|
423 |
lightColor := White.
|
|
424 |
shadowColor := Black.
|
|
425 |
halfShadowColor := Color darkGrey.
|
|
426 |
halfLightColor := White.
|
|
427 |
] ifFalse:[
|
|
428 |
viewBackground := White.
|
|
429 |
lightColor := Color grey
|
|
430 |
"or White"
|
|
431 |
"or Color lightGrey". "cant say which is better ..."
|
|
432 |
shadowColor := Black.
|
|
433 |
halfShadowColor := Color grey.
|
|
434 |
halfLightColor := White.
|
|
435 |
].
|
|
436 |
|
|
437 |
borderColor := Black.
|
|
438 |
!
|
|
439 |
|
|
440 |
initEvents
|
|
441 |
"will be sent by create - can be redefined by subclasses to enable
|
|
442 |
view events"
|
|
443 |
|
|
444 |
^ self
|
|
445 |
!
|
|
446 |
|
12
|
447 |
prepareForReinit
|
|
448 |
super prepareForReinit.
|
|
449 |
windowGroup notNil ifTrue:[
|
15
|
450 |
windowGroup reinitialize
|
12
|
451 |
]
|
|
452 |
!
|
|
453 |
|
0
|
454 |
reinitialize
|
|
455 |
"this is called right after snapIn"
|
|
456 |
|
|
457 |
|myController|
|
|
458 |
|
|
459 |
"if I have already been reinited - return"
|
|
460 |
drawableId notNil ifTrue:[
|
|
461 |
^ self
|
|
462 |
].
|
|
463 |
|
|
464 |
myController := controller.
|
|
465 |
controller := nil.
|
|
466 |
self recreate.
|
|
467 |
|
|
468 |
"if I was mapped, do it again"
|
|
469 |
realized ifTrue:[
|
|
470 |
"if it was iconified, try to remap iconified"
|
|
471 |
shown ifFalse:[
|
|
472 |
device mapWindow:drawableId iconified:true
|
|
473 |
atX:left y:top
|
|
474 |
width:width height:height
|
|
475 |
] ifTrue:[
|
|
476 |
device mapWindow:drawableId iconified:false
|
|
477 |
atX:left y:top
|
|
478 |
width:width height:height
|
12
|
479 |
].
|
|
480 |
|
|
481 |
"and restart the window-group process"
|
|
482 |
windowGroup notNil ifTrue:[
|
|
483 |
windowGroup startup
|
0
|
484 |
]
|
|
485 |
].
|
|
486 |
|
|
487 |
"restore controller"
|
|
488 |
controller := myController
|
|
489 |
!
|
|
490 |
|
12
|
491 |
reinitStyle
|
|
492 |
"this method is called for a style change"
|
|
493 |
|
|
494 |
|t|
|
|
495 |
|
|
496 |
Grey := nil.
|
|
497 |
DefaultStyle := nil.
|
|
498 |
|
|
499 |
self initStyle.
|
|
500 |
|
|
501 |
drawableId notNil ifTrue:[
|
|
502 |
"force a change"
|
|
503 |
t := borderWidth. borderWidth := nil. self borderWidth:t.
|
|
504 |
t := viewBackground. viewBackground := nil. self viewBackground:t.
|
|
505 |
self clear.
|
|
506 |
self redraw
|
|
507 |
].
|
|
508 |
!
|
|
509 |
|
0
|
510 |
recreate
|
|
511 |
"recreate (i.e. tell X about me) after a snapin"
|
|
512 |
|
|
513 |
drawableId isNil ifTrue:[
|
|
514 |
"associate cursor/colors to device"
|
|
515 |
|
|
516 |
super recreate.
|
|
517 |
|
|
518 |
borderColor notNil ifTrue:[
|
|
519 |
borderColor := borderColor on:device.
|
|
520 |
].
|
|
521 |
shadowColor notNil ifTrue:[
|
|
522 |
shadowColor := shadowColor on:device.
|
|
523 |
].
|
|
524 |
lightColor notNil ifTrue:[
|
|
525 |
lightColor := lightColor on:device.
|
|
526 |
].
|
|
527 |
halfShadowColor notNil ifTrue:[
|
|
528 |
halfShadowColor := halfShadowColor on:device.
|
|
529 |
].
|
|
530 |
halfLightColor notNil ifTrue:[
|
|
531 |
halfLightColor := halfLightColor on:device.
|
|
532 |
].
|
|
533 |
|
|
534 |
drawableId := device createWindowFor:self
|
|
535 |
left:left top:top
|
|
536 |
width:width height:height.
|
|
537 |
|
|
538 |
extentChanged := false.
|
|
539 |
originChanged := false.
|
|
540 |
|
|
541 |
borderShape notNil ifTrue:[
|
|
542 |
device setWindowBorderShape:(borderShape id) in:drawableId
|
|
543 |
].
|
|
544 |
viewShape notNil ifTrue:[
|
|
545 |
device setWindowShape:(viewShape id) in:drawableId
|
|
546 |
].
|
2
|
547 |
(backed notNil and:[backed ~~ false]) ifTrue:[
|
0
|
548 |
device setBackingStore:backed in:drawableId
|
|
549 |
].
|
|
550 |
saveUnder ifTrue:[
|
|
551 |
device setSaveUnder:saveUnder in:drawableId
|
|
552 |
].
|
|
553 |
|
|
554 |
font := font on:device.
|
|
555 |
|
|
556 |
"XXX has to be changed: eventmasks are device specific -
|
|
557 |
will not allow restart on another Workstation-type"
|
|
558 |
|
|
559 |
device setEventMask:eventMask in:drawableId
|
|
560 |
]
|
|
561 |
! !
|
|
562 |
|
|
563 |
!View methodsFor:'accessing-mvc'!
|
|
564 |
|
12
|
565 |
windowGroup
|
|
566 |
"return the window group. For old style views, return nil"
|
|
567 |
|
|
568 |
^ windowGroup
|
|
569 |
!
|
|
570 |
|
0
|
571 |
controller
|
|
572 |
"return the controller. For non MVC views, return nil"
|
|
573 |
|
|
574 |
^ controller
|
|
575 |
!
|
|
576 |
|
|
577 |
controller:aController
|
|
578 |
"set the controller"
|
|
579 |
|
|
580 |
controller := aController.
|
|
581 |
controller view:self.
|
|
582 |
controller model:model
|
|
583 |
!
|
|
584 |
|
|
585 |
model
|
|
586 |
"return the model, for non-MVC views,
|
|
587 |
this is usually the receiver"
|
|
588 |
|
|
589 |
^ model
|
|
590 |
!
|
|
591 |
|
|
592 |
model:aModel
|
|
593 |
"set the model"
|
|
594 |
|
|
595 |
model notNil ifTrue:[
|
|
596 |
model removeDependent:self
|
|
597 |
].
|
|
598 |
model := aModel.
|
|
599 |
model notNil ifTrue:[
|
|
600 |
aModel addDependent:self
|
|
601 |
].
|
|
602 |
controller notNil ifTrue:[
|
|
603 |
controller model:aModel
|
|
604 |
]
|
|
605 |
!
|
|
606 |
|
|
607 |
on: anObject aspect: aspectMsg change: changeMsg menu: menuMsg
|
12
|
608 |
"ST-80 compatibility: set model, aspect, change and menu
|
|
609 |
messages - needs a view which uses these"
|
|
610 |
|
0
|
611 |
self model:anObject.
|
|
612 |
self aspect:aspectMsg.
|
|
613 |
self change:changeMsg.
|
|
614 |
self menu:menuMsg
|
|
615 |
!
|
|
616 |
|
|
617 |
aspect:aspectMsg
|
12
|
618 |
aspectSymbol := aspectMsg
|
0
|
619 |
!
|
|
620 |
|
|
621 |
change:changeMsg
|
12
|
622 |
changeSymbol := changeMsg
|
0
|
623 |
!
|
|
624 |
|
|
625 |
menu:menuMsg
|
12
|
626 |
menuSymbol := menuMsg
|
0
|
627 |
!
|
|
628 |
|
|
629 |
heightOfContents
|
|
630 |
"return the height of the contents in pixels
|
|
631 |
- defaults to views visible area here"
|
|
632 |
|
|
633 |
^ self innerHeight
|
|
634 |
!
|
|
635 |
|
|
636 |
widthOfContents
|
|
637 |
"return the width of the contents in pixels
|
|
638 |
- defaults to views visible area here"
|
|
639 |
|
|
640 |
^ self innerWidth
|
|
641 |
! !
|
|
642 |
|
|
643 |
!View methodsFor:'accessing-dimensions'!
|
|
644 |
|
|
645 |
left:aNumber
|
|
646 |
"set the x position"
|
|
647 |
|
|
648 |
self origin:(aNumber @ top)
|
|
649 |
!
|
|
650 |
|
|
651 |
top:aNumber
|
|
652 |
"set the y position"
|
|
653 |
|
|
654 |
self origin:(left @ aNumber)
|
|
655 |
!
|
|
656 |
|
|
657 |
width:aNumber
|
|
658 |
"set the views width in pixels"
|
|
659 |
|
|
660 |
self extent:(aNumber @ height)
|
|
661 |
!
|
|
662 |
|
|
663 |
height:aNumber
|
|
664 |
"set the views height in pixels"
|
|
665 |
|
|
666 |
self extent:(width @ aNumber)
|
|
667 |
!
|
|
668 |
|
|
669 |
innerWidth
|
|
670 |
"return the width of the view minus any shadow-borders"
|
|
671 |
|
|
672 |
(level == 0) ifTrue:[^ width].
|
|
673 |
^ width - (2 * margin)
|
|
674 |
!
|
|
675 |
|
|
676 |
innerHeight
|
|
677 |
"return the height of the view minus any shadow-borders"
|
|
678 |
|
|
679 |
(margin == 0) ifTrue:[^ height].
|
|
680 |
^ height - (2 * margin)
|
|
681 |
!
|
|
682 |
|
|
683 |
extent:extent
|
|
684 |
"set the views extent; extent may be:
|
|
685 |
a point where integer fields mean pixel-values
|
|
686 |
and float values mean relative-to-superview;
|
|
687 |
or a block returning a point"
|
|
688 |
|
|
689 |
|w h e|
|
|
690 |
|
|
691 |
extent isBlock ifTrue:[
|
|
692 |
extentRule := extent.
|
12
|
693 |
"shown " drawableId notNil " " ifTrue:[ "23-feb-93"
|
0
|
694 |
self pixelExtent:(extent value)
|
|
695 |
] ifFalse:[
|
|
696 |
extentChanged := true
|
|
697 |
]
|
|
698 |
] ifFalse:[
|
|
699 |
w := extent x.
|
|
700 |
h := extent y.
|
|
701 |
((w isMemberOf:Float) or:[h isMemberOf:Float]) ifTrue:[
|
|
702 |
relativeExtent := extent.
|
|
703 |
e := self extentFromRelativeExtent.
|
|
704 |
e isNil ifTrue:[
|
|
705 |
extentChanged := true
|
|
706 |
] ifFalse:[
|
|
707 |
self pixelExtent:e
|
|
708 |
]
|
|
709 |
] ifFalse:[
|
|
710 |
self pixelExtent:extent
|
|
711 |
]
|
|
712 |
]
|
|
713 |
!
|
|
714 |
|
|
715 |
origin:origin
|
|
716 |
"set the views origin; origin may be:
|
|
717 |
a point where integer fields mean pixel-values
|
|
718 |
and float values mean relative-to-superview;
|
|
719 |
or a block returning a point"
|
|
720 |
|
|
721 |
|newLeft newTop o|
|
|
722 |
|
|
723 |
origin isBlock ifTrue:[
|
|
724 |
originRule := origin.
|
|
725 |
drawableId notNil ifTrue:[
|
|
726 |
self pixelOrigin:(origin value)
|
|
727 |
] ifFalse:[
|
|
728 |
originChanged := true
|
|
729 |
]
|
|
730 |
] ifFalse:[
|
|
731 |
newLeft := origin x.
|
|
732 |
newTop := origin y.
|
|
733 |
((newLeft isMemberOf:Float) or:[newTop isMemberOf:Float]) ifTrue:[
|
|
734 |
relativeOrigin := origin.
|
|
735 |
o := self originFromRelativeOrigin.
|
|
736 |
o isNil ifTrue:[
|
|
737 |
originChanged := true
|
|
738 |
] ifFalse:[
|
|
739 |
self pixelOrigin:o
|
|
740 |
]
|
|
741 |
] ifFalse:[
|
|
742 |
self pixelOrigin:origin
|
|
743 |
]
|
|
744 |
]
|
|
745 |
!
|
|
746 |
|
|
747 |
origin:origin corner:corner
|
|
748 |
"set both origin and extent"
|
|
749 |
|
|
750 |
|newLeft newTop newRight newBot|
|
|
751 |
|
|
752 |
"do it as one operation if possible"
|
|
753 |
|
|
754 |
origin isBlock ifFalse:[
|
|
755 |
corner isBlock ifFalse:[
|
|
756 |
newLeft := origin x.
|
|
757 |
(newLeft isMemberOf:Float) ifFalse:[
|
|
758 |
newTop := origin y.
|
|
759 |
(newTop isMemberOf:Float) ifFalse:[
|
|
760 |
newRight := corner x.
|
|
761 |
(newRight isMemberOf:Float) ifFalse:[
|
|
762 |
newBot := corner y.
|
|
763 |
(newBot isMemberOf:Float) ifFalse:[
|
|
764 |
self pixelOrigin:origin corner:corner
|
|
765 |
]
|
|
766 |
]
|
|
767 |
]
|
|
768 |
]
|
|
769 |
]
|
|
770 |
].
|
|
771 |
self origin:origin.
|
|
772 |
self corner:corner
|
|
773 |
!
|
|
774 |
|
|
775 |
origin:origin extent:extent
|
|
776 |
"set both origin and extent"
|
|
777 |
|
|
778 |
|newLeft newTop newWidth newHeight|
|
|
779 |
|
|
780 |
"do it as one operation if possible"
|
|
781 |
|
|
782 |
origin isBlock ifFalse:[
|
|
783 |
extent isBlock ifFalse:[
|
|
784 |
newLeft := origin x.
|
|
785 |
(newLeft isMemberOf:Float) ifFalse:[
|
|
786 |
newTop := origin y.
|
|
787 |
(newTop isMemberOf:Float) ifFalse:[
|
|
788 |
newWidth := extent x.
|
|
789 |
(newWidth isMemberOf:Float) ifFalse:[
|
|
790 |
newHeight := extent y.
|
|
791 |
(newHeight isMemberOf:Float) ifFalse:[
|
|
792 |
self pixelOrigin:origin extent:extent
|
|
793 |
]
|
|
794 |
]
|
|
795 |
]
|
|
796 |
]
|
|
797 |
]
|
|
798 |
].
|
|
799 |
self extent:extent.
|
|
800 |
self origin:origin
|
|
801 |
!
|
|
802 |
|
|
803 |
left:newLeft top:newTop width:newWidth height:newHeight
|
|
804 |
"another way of specifying origin and extent"
|
|
805 |
|
|
806 |
self origin:(newLeft @ newTop) extent:(newWidth @ newHeight)
|
|
807 |
!
|
|
808 |
|
|
809 |
relativeOrigin
|
|
810 |
"return the relative origin or nil"
|
|
811 |
|
|
812 |
^ relativeOrigin
|
|
813 |
!
|
|
814 |
|
|
815 |
relativeCorner
|
|
816 |
"return the relative corner or nil"
|
|
817 |
|
|
818 |
^ relativeCorner
|
|
819 |
!
|
|
820 |
|
|
821 |
relativeExtent
|
|
822 |
"return the relative extent or nil"
|
|
823 |
|
|
824 |
^ relativeExtent
|
|
825 |
!
|
|
826 |
|
|
827 |
relativeOrigin:aPoint
|
|
828 |
"set the relative origin"
|
|
829 |
|
|
830 |
relativeOrigin := aPoint
|
|
831 |
!
|
|
832 |
|
|
833 |
relativeCorner:aPoint
|
|
834 |
"set the relative corner"
|
|
835 |
|
|
836 |
relativeCorner := aPoint
|
|
837 |
!
|
|
838 |
|
|
839 |
relativeExtent:aPoint
|
|
840 |
"set the relative extent"
|
|
841 |
|
|
842 |
relativeExtent := aPoint
|
|
843 |
!
|
|
844 |
|
|
845 |
center:newCenter
|
|
846 |
"move the receiver so that newCenter, aPoint becomes the center point"
|
|
847 |
|
|
848 |
self origin:(newCenter - ((width // 2) @ (height // 2)))
|
|
849 |
!
|
|
850 |
|
|
851 |
center
|
|
852 |
"return the point at the center of the receiver"
|
|
853 |
|
|
854 |
^ (left + (width // 2)) @ (top + (height // 2))
|
|
855 |
!
|
|
856 |
|
|
857 |
origin
|
|
858 |
"return the origin (in pixels)"
|
|
859 |
|
|
860 |
^ left@top
|
|
861 |
!
|
|
862 |
|
|
863 |
originRelativeTo:aView
|
|
864 |
"return the origin (in pixels) relative to a superView"
|
|
865 |
|
|
866 |
|currentView
|
|
867 |
org "{ Class: Point }"
|
|
868 |
sumX "{ Class: SmallInteger }"
|
|
869 |
sumY "{ Class: SmallInteger }" |
|
|
870 |
|
|
871 |
currentView := self.
|
|
872 |
sumX := 0.
|
|
873 |
sumY := 0.
|
|
874 |
[currentView notNil] whileTrue:[
|
|
875 |
(currentView == aView) ifTrue:[
|
|
876 |
^ (sumX @ sumY)
|
|
877 |
].
|
|
878 |
org := currentView origin.
|
|
879 |
sumX := sumX + org x.
|
|
880 |
sumY := sumY + org y.
|
|
881 |
currentView := currentView superView
|
|
882 |
].
|
|
883 |
^ nil
|
|
884 |
!
|
|
885 |
|
|
886 |
left
|
|
887 |
"return the x position of the left border"
|
|
888 |
|
|
889 |
^ left
|
|
890 |
!
|
|
891 |
|
|
892 |
right
|
|
893 |
"return the x position of the right border"
|
|
894 |
|
|
895 |
^ left + width - 1
|
|
896 |
!
|
|
897 |
|
|
898 |
top
|
|
899 |
"return the y position of the top border"
|
|
900 |
|
|
901 |
^ top
|
|
902 |
!
|
|
903 |
|
|
904 |
bottom
|
|
905 |
"return the y position of the bottom border"
|
|
906 |
|
|
907 |
^ top + height - 1
|
|
908 |
!
|
|
909 |
|
|
910 |
corner
|
|
911 |
"return the lower right corner-point"
|
|
912 |
|
|
913 |
^ (left + width - 1) @ (top + height - 1)
|
|
914 |
!
|
|
915 |
|
|
916 |
corner:corner
|
|
917 |
"set the views corner; corner may be:
|
|
918 |
a point where integer fields mean pixel-values
|
|
919 |
and float values mean relative-to-superview;
|
|
920 |
or a block returning a point"
|
|
921 |
|
|
922 |
|x y c|
|
|
923 |
|
|
924 |
corner isBlock ifTrue:[
|
|
925 |
cornerRule := corner.
|
|
926 |
drawableId notNil ifTrue:[
|
|
927 |
self pixelCorner:(corner value)
|
|
928 |
] ifFalse:[
|
|
929 |
extentChanged := true
|
|
930 |
]
|
|
931 |
] ifFalse:[
|
|
932 |
x := corner x.
|
|
933 |
y := corner y.
|
|
934 |
((x isMemberOf:Float) or:[y isMemberOf:Float]) ifTrue:[
|
|
935 |
relativeCorner := corner.
|
|
936 |
c := self cornerFromRelativeCorner.
|
|
937 |
c isNil ifTrue:[
|
|
938 |
extentChanged := true
|
|
939 |
] ifFalse:[
|
|
940 |
self pixelCorner:c
|
|
941 |
]
|
|
942 |
] ifFalse:[
|
|
943 |
self pixelCorner:corner
|
|
944 |
]
|
|
945 |
]
|
|
946 |
! !
|
|
947 |
|
|
948 |
!View methodsFor:'accessing-transformation'!
|
|
949 |
|
|
950 |
window
|
|
951 |
^ window
|
|
952 |
!
|
|
953 |
|
|
954 |
window:aRectangle
|
|
955 |
window := aRectangle.
|
|
956 |
subViews notNil ifTrue:[
|
|
957 |
subViews do:[:s |
|
|
958 |
s superViewChangedSize
|
|
959 |
]
|
|
960 |
]
|
|
961 |
|
|
962 |
"
|
|
963 |
viewport isNil ifTrue:[
|
|
964 |
viewport := aRectangle.
|
|
965 |
].
|
|
966 |
"
|
|
967 |
"
|
|
968 |
superView notNil ifTrue:[
|
|
969 |
self superViewChangedSize
|
|
970 |
] ifFalse:[
|
|
971 |
originChanged := true.
|
|
972 |
extentChanged := true
|
|
973 |
]
|
|
974 |
"
|
|
975 |
!
|
|
976 |
|
|
977 |
window:aRectangle viewport:vRect
|
|
978 |
window := aRectangle.
|
|
979 |
self viewport:vRect.
|
|
980 |
subViews notNil ifTrue:[
|
|
981 |
subViews do:[:s |
|
|
982 |
s superViewChangedSize
|
|
983 |
]
|
|
984 |
]
|
|
985 |
!
|
|
986 |
|
|
987 |
transformation
|
|
988 |
transformation isNil ifTrue:[
|
|
989 |
superView isNil ifTrue:[
|
|
990 |
transformation := WindowingTransformation window:window
|
|
991 |
viewport:(0@0 extent:self extent)
|
|
992 |
] ifFalse:[
|
|
993 |
window isNil ifTrue:[
|
|
994 |
window := (0 @ 0) corner:(1 @ 1)
|
|
995 |
].
|
|
996 |
transformation := WindowingTransformation window:window
|
|
997 |
viewport:(self origin extent:self extent)
|
|
998 |
]
|
|
999 |
].
|
|
1000 |
^ transformation
|
|
1001 |
!
|
|
1002 |
|
|
1003 |
displayTransformation
|
|
1004 |
"ST-80 compatibility - ST/X does not draw onto the display"
|
|
1005 |
|
|
1006 |
^ self transformation
|
|
1007 |
!
|
|
1008 |
|
|
1009 |
displayTransform:aPoint
|
|
1010 |
"given a point in window coordinate, make pixel coordinate"
|
|
1011 |
|
|
1012 |
|nx ny|
|
|
1013 |
|
|
1014 |
nx := aPoint x - window left * width / window width.
|
|
1015 |
ny := aPoint y - window top * height / window height.
|
|
1016 |
^ nx @ ny
|
|
1017 |
!
|
|
1018 |
|
|
1019 |
inverseDisplayTransform:aPoint
|
|
1020 |
"given a pixel coordinate, make window coordinate"
|
|
1021 |
|
|
1022 |
|nx ny|
|
|
1023 |
|
|
1024 |
window isNil ifTrue:[^ aPoint].
|
|
1025 |
nx := aPoint x * window width / width + window left.
|
|
1026 |
ny := aPoint y * window height / height + window top.
|
|
1027 |
^ nx @ ny
|
|
1028 |
!
|
|
1029 |
|
|
1030 |
viewport:aRectangle
|
|
1031 |
"define my extend in my superviews coordinate-system."
|
|
1032 |
|
|
1033 |
|relW relH relX relY winW winH|
|
|
1034 |
|
|
1035 |
viewport := aRectangle.
|
|
1036 |
self dimensionFromViewport
|
|
1037 |
"
|
|
1038 |
superView notNil ifTrue:[
|
|
1039 |
superView window isNil ifTrue:[
|
|
1040 |
winW := 1.
|
|
1041 |
winH := 1
|
|
1042 |
] ifFalse:[
|
|
1043 |
winW := superView window width.
|
|
1044 |
winH := superView window height
|
|
1045 |
].
|
|
1046 |
relW := (aRectangle width / winW) asFloat.
|
|
1047 |
relH := (aRectangle height / winH) asFloat.
|
|
1048 |
relX := (aRectangle left / winW) asFloat.
|
|
1049 |
relY := (aRectangle top / winH) asFloat.
|
|
1050 |
self origin:(relX @ relY) extent:(relW @ relH)
|
|
1051 |
]
|
|
1052 |
"
|
|
1053 |
!
|
|
1054 |
|
|
1055 |
viewRectangle
|
|
1056 |
"return the inside area"
|
|
1057 |
|
|
1058 |
|m2|
|
|
1059 |
|
|
1060 |
innerClipRect notNil ifTrue:[
|
|
1061 |
^ innerClipRect
|
|
1062 |
].
|
|
1063 |
m2 := margin + margin.
|
|
1064 |
|
|
1065 |
^ (margin @ margin) extent:((width - m2) @ (height - m2))
|
|
1066 |
!
|
|
1067 |
|
|
1068 |
viewOrigin
|
|
1069 |
"return the viewOrigin; thats the coordinate of the contents
|
|
1070 |
which is shown topLeft in the view
|
|
1071 |
(i.e. the origin of the visible part of the contents)."
|
|
1072 |
|
|
1073 |
^ viewOrigin
|
|
1074 |
!
|
|
1075 |
|
|
1076 |
viewOrigin:aPoint
|
|
1077 |
"set the viewOrigin - i.e. virtually scroll without redrawing"
|
|
1078 |
|
|
1079 |
viewOrigin := aPoint
|
|
1080 |
!
|
|
1081 |
|
|
1082 |
xOriginOfContents
|
|
1083 |
"return the x coordinate of the viewOrigin; used by scrollBars to compute
|
|
1084 |
thumb position"
|
|
1085 |
|
|
1086 |
^ viewOrigin x
|
|
1087 |
!
|
|
1088 |
|
|
1089 |
yOriginOfContents
|
|
1090 |
"return the y coordinate of the viewOrigin; used by scrollBars to compute
|
|
1091 |
thumb position"
|
|
1092 |
|
|
1093 |
^ viewOrigin y
|
|
1094 |
! !
|
|
1095 |
|
|
1096 |
!View methodsFor:'accessing-hierarchy'!
|
|
1097 |
|
|
1098 |
superView
|
|
1099 |
"return my superView"
|
|
1100 |
|
|
1101 |
^ superView
|
|
1102 |
!
|
|
1103 |
|
|
1104 |
superView:aView
|
|
1105 |
"set my superView to be aView"
|
|
1106 |
|
|
1107 |
superView := aView
|
|
1108 |
!
|
|
1109 |
|
|
1110 |
topView
|
|
1111 |
"return the topView - thats the one with no superview"
|
|
1112 |
|
|
1113 |
|v|
|
|
1114 |
|
|
1115 |
v := self.
|
|
1116 |
[v notNil] whileTrue:[
|
|
1117 |
v superView isNil ifTrue:[^ v].
|
|
1118 |
v := v superView
|
|
1119 |
].
|
|
1120 |
|
|
1121 |
^ nil
|
|
1122 |
!
|
|
1123 |
|
|
1124 |
subViews
|
|
1125 |
"return the collection of subviews"
|
|
1126 |
|
|
1127 |
^ subViews
|
|
1128 |
!
|
|
1129 |
|
|
1130 |
subViews:aListOfViews
|
|
1131 |
"set the collection of subviews"
|
|
1132 |
|
|
1133 |
subViews := aListOfViews.
|
|
1134 |
subViews notNil ifTrue:[
|
|
1135 |
subViews do:[:view |
|
|
1136 |
view superView:self
|
|
1137 |
]
|
|
1138 |
]
|
|
1139 |
! !
|
|
1140 |
|
|
1141 |
!View methodsFor:'accessing-misc'!
|
|
1142 |
|
|
1143 |
viewGravity
|
|
1144 |
"return the viewGravity - thats the direction where the view will move
|
|
1145 |
when the superView is resized."
|
|
1146 |
|
|
1147 |
^ viewGravity
|
|
1148 |
!
|
|
1149 |
|
|
1150 |
viewGravity:gravity
|
|
1151 |
"set the viewGravity - thats the direction where the view will move
|
|
1152 |
when the superView is resized."
|
|
1153 |
|
|
1154 |
viewGravity := gravity
|
|
1155 |
!
|
|
1156 |
|
|
1157 |
bitGravity
|
|
1158 |
"return the bitGravity - thats the direction where the contents will move
|
|
1159 |
when the the view is resized."
|
|
1160 |
|
|
1161 |
^ bitGravity
|
|
1162 |
!
|
|
1163 |
|
|
1164 |
inputOnly
|
|
1165 |
"return true, if this view is an input-only view;
|
|
1166 |
input only views are transparent and can be layed on top of a view to
|
|
1167 |
catch its input"
|
|
1168 |
|
|
1169 |
^ false
|
|
1170 |
!
|
|
1171 |
|
|
1172 |
createOnTop
|
|
1173 |
"return true, if this view should be put on top (raised) automatically.
|
|
1174 |
usually this is true for alertBoxes etc."
|
|
1175 |
|
|
1176 |
^ false
|
|
1177 |
!
|
|
1178 |
|
|
1179 |
canDrop:anObjectOrCollection
|
|
1180 |
"return true, if anObjectOrCollection can be
|
|
1181 |
dropped in the receiver. This method should be
|
|
1182 |
redefined in views which can take objects"
|
|
1183 |
|
|
1184 |
^ false
|
|
1185 |
!
|
|
1186 |
|
|
1187 |
is3D
|
12
|
1188 |
"return true, if my style is some kind of 3D style - will change"
|
|
1189 |
|
0
|
1190 |
^ #(next iris openwin view3D motif) includes:style
|
|
1191 |
!
|
|
1192 |
|
|
1193 |
shown
|
|
1194 |
"return true if the view is shown; false if hidden"
|
|
1195 |
|
|
1196 |
^ shown
|
|
1197 |
!
|
|
1198 |
|
|
1199 |
isCollapsed
|
12
|
1200 |
"ST80 compatibility: return true if the view is not shown (i.e. iconified)"
|
|
1201 |
|
0
|
1202 |
^ shown not
|
|
1203 |
!
|
|
1204 |
|
|
1205 |
hidden:aBoolean
|
|
1206 |
"if the argument is true, the receiver view will not
|
|
1207 |
be realized automatically when superview is realized"
|
|
1208 |
|
|
1209 |
hidden := aBoolean
|
|
1210 |
!
|
|
1211 |
|
|
1212 |
hidden
|
|
1213 |
"return true, if the view does not want to be realized
|
|
1214 |
automatically when superview is realized"
|
|
1215 |
|
|
1216 |
^ hidden
|
|
1217 |
!
|
|
1218 |
|
|
1219 |
lower
|
|
1220 |
"bring to back"
|
|
1221 |
|
|
1222 |
drawableId isNil ifTrue:[self create].
|
|
1223 |
device lowerWindow:drawableId
|
|
1224 |
!
|
|
1225 |
|
|
1226 |
raise
|
|
1227 |
"bring to front"
|
|
1228 |
|
|
1229 |
drawableId isNil ifTrue:[self create].
|
|
1230 |
device raiseWindow:drawableId
|
|
1231 |
! !
|
|
1232 |
|
|
1233 |
!View methodsFor:'accessing-bg & border'!
|
|
1234 |
|
|
1235 |
viewBackground:something
|
|
1236 |
"set the viewBackground to something, a color, pixel or form.
|
|
1237 |
if its a color and we run on a color display, also set shadow and light
|
|
1238 |
colors."
|
|
1239 |
|
|
1240 |
(something isKindOf:Color) ifTrue:[
|
|
1241 |
(device hasColors or:[device hasGreyscales]) ifTrue:[
|
|
1242 |
shadowColor := something darkened.
|
|
1243 |
lightColor := something lightened
|
|
1244 |
]
|
|
1245 |
].
|
|
1246 |
super viewBackground:something
|
|
1247 |
!
|
|
1248 |
|
|
1249 |
borderColor
|
|
1250 |
"return my borderColor"
|
|
1251 |
|
|
1252 |
^ borderColor
|
|
1253 |
!
|
|
1254 |
|
|
1255 |
borderColor:aColor
|
|
1256 |
"set my borderColor"
|
|
1257 |
|
|
1258 |
|id dither|
|
|
1259 |
|
|
1260 |
(aColor ~~ borderColor) ifTrue:[
|
|
1261 |
borderColor := aColor.
|
|
1262 |
drawableId notNil ifTrue:[
|
|
1263 |
borderColor := borderColor on:device.
|
|
1264 |
id := borderColor colorId.
|
|
1265 |
id notNil ifTrue:[
|
|
1266 |
device setWindowBorderColor:id in:drawableId
|
|
1267 |
] ifFalse:[
|
|
1268 |
dither := borderColor ditherForm.
|
|
1269 |
dither notNil ifTrue:[
|
|
1270 |
device setWindowBorderPixmap:(dither id) in:drawableId
|
|
1271 |
] ifFalse:[
|
|
1272 |
'bad borderColor' printNewline
|
|
1273 |
]
|
|
1274 |
]
|
|
1275 |
]
|
|
1276 |
]
|
|
1277 |
!
|
|
1278 |
|
|
1279 |
borderWidth
|
|
1280 |
"return my borderWidth"
|
|
1281 |
|
|
1282 |
^ borderWidth
|
|
1283 |
!
|
|
1284 |
|
|
1285 |
borderWidth:aNumber
|
|
1286 |
"set my borderWidth"
|
|
1287 |
|
|
1288 |
(aNumber ~~ borderWidth) ifTrue:[
|
|
1289 |
borderWidth := aNumber.
|
|
1290 |
drawableId notNil ifTrue:[
|
|
1291 |
device setWindowBorderWidth:aNumber in:drawableId
|
|
1292 |
]
|
|
1293 |
]
|
|
1294 |
!
|
|
1295 |
|
|
1296 |
borderShape:aForm
|
|
1297 |
"set the borderShape to aForm"
|
|
1298 |
|
|
1299 |
borderShape := aForm.
|
|
1300 |
drawableId notNil ifTrue:[
|
|
1301 |
device setWindowBorderShape:(aForm id) in:drawableId
|
|
1302 |
]
|
|
1303 |
!
|
|
1304 |
|
|
1305 |
viewShape:aForm
|
|
1306 |
"set the viewShape to aForm"
|
|
1307 |
|
|
1308 |
viewShape := aForm.
|
|
1309 |
drawableId notNil ifTrue:[
|
|
1310 |
device setWindowShape:(aForm id) in:drawableId
|
|
1311 |
]
|
|
1312 |
!
|
|
1313 |
|
|
1314 |
name
|
|
1315 |
"return my name component to be used for resource-access"
|
|
1316 |
|
|
1317 |
^ name
|
|
1318 |
!
|
|
1319 |
|
|
1320 |
fullName
|
|
1321 |
"return my full name to be used for resource-access"
|
|
1322 |
|
|
1323 |
superView notNil ifTrue:[
|
|
1324 |
^ superView fullName , '.' , name
|
|
1325 |
].
|
|
1326 |
^ name
|
|
1327 |
!
|
|
1328 |
|
|
1329 |
name:aString
|
|
1330 |
"set my name component to be used for resource-access"
|
|
1331 |
|
|
1332 |
name := aString
|
|
1333 |
!
|
|
1334 |
|
|
1335 |
keyboardHandler:someOne
|
|
1336 |
"set my keyboardHandler"
|
|
1337 |
|
|
1338 |
keyboardHandler := someOne
|
|
1339 |
!
|
|
1340 |
|
|
1341 |
level
|
|
1342 |
"return my level relative to superView (3D)"
|
|
1343 |
|
|
1344 |
^ level
|
|
1345 |
!
|
|
1346 |
|
|
1347 |
level:aNumber
|
|
1348 |
"set my level relative to superView (3D)"
|
|
1349 |
|
|
1350 |
|oldMargin how|
|
|
1351 |
|
|
1352 |
self is3D ifTrue:[
|
|
1353 |
(aNumber ~~ level) ifTrue:[
|
|
1354 |
level := aNumber.
|
|
1355 |
oldMargin := margin.
|
|
1356 |
margin := level abs.
|
|
1357 |
|
|
1358 |
realized ifTrue:[
|
|
1359 |
(margin > oldMargin) ifTrue:[
|
|
1360 |
how := #smaller
|
|
1361 |
] ifFalse:[
|
|
1362 |
how := #larger
|
|
1363 |
].
|
12
|
1364 |
self sizeChanged:how.
|
0
|
1365 |
self computeInnerClip.
|
|
1366 |
self redrawEdges
|
|
1367 |
]
|
|
1368 |
]
|
|
1369 |
]
|
|
1370 |
!
|
|
1371 |
|
|
1372 |
margin
|
|
1373 |
"return my margin - this is usually the level,
|
|
1374 |
but can be more for some views"
|
|
1375 |
|
|
1376 |
^ margin
|
|
1377 |
!
|
|
1378 |
|
|
1379 |
widthIncludingBorder
|
|
1380 |
"return my width including border"
|
|
1381 |
|
|
1382 |
^ width + (2*borderWidth)
|
|
1383 |
!
|
|
1384 |
|
|
1385 |
heightIncludingBorder
|
|
1386 |
"return my height including border"
|
|
1387 |
|
|
1388 |
^ height + (2*borderWidth)
|
|
1389 |
! !
|
|
1390 |
|
|
1391 |
!View methodsFor:'adding & removing components'!
|
|
1392 |
|
|
1393 |
addComponent:aComponent
|
|
1394 |
components isNil ifTrue:[
|
|
1395 |
components := IdentitySet new
|
|
1396 |
].
|
|
1397 |
components add:aComponent
|
|
1398 |
!
|
|
1399 |
|
|
1400 |
removeComponent:aComponent
|
|
1401 |
components isNil ifTrue:[^self].
|
|
1402 |
components remove:aComponent ifAbsent:[]
|
|
1403 |
!
|
|
1404 |
|
|
1405 |
addSubView:aView
|
|
1406 |
"add a view to the collection of subviews"
|
|
1407 |
|
|
1408 |
subViews isNil ifTrue:[
|
|
1409 |
subViews := OrderedCollection new
|
|
1410 |
].
|
|
1411 |
subViews add:aView.
|
|
1412 |
aView superView:self.
|
|
1413 |
(aView device ~~ device) ifTrue:[
|
|
1414 |
'warning subview (' print. aView class name print.
|
|
1415 |
') has different device than me (' print.
|
|
1416 |
self class name print. ').' printNewline.
|
|
1417 |
aView device:device
|
|
1418 |
]
|
|
1419 |
!
|
|
1420 |
|
|
1421 |
addSubView:aView in:bounds borderWidth:bw
|
|
1422 |
aView borderWidth:bw.
|
|
1423 |
aView origin:(bounds origin x asFloat) @ (bounds origin y asFloat)
|
|
1424 |
extent:(bounds extent x asFloat) @ (bounds extent y asFloat).
|
|
1425 |
self addSubView:aView
|
|
1426 |
!
|
|
1427 |
|
|
1428 |
add:aView in:bounds
|
|
1429 |
aView origin:(bounds origin x asFloat) @ (bounds origin y asFloat)
|
|
1430 |
extent:(bounds extent x asFloat) @ (bounds extent y asFloat).
|
|
1431 |
self addSubView:aView
|
|
1432 |
!
|
|
1433 |
|
|
1434 |
addSubView:aView viewport:aRectangle
|
|
1435 |
"Adds aView to the views list of subviews and uses the
|
|
1436 |
existing subviews window and the new viewport to position it"
|
|
1437 |
|
|
1438 |
self addSubView:aView.
|
|
1439 |
aView viewport:aRectangle
|
|
1440 |
!
|
|
1441 |
|
|
1442 |
addSubView:aView window:aWindowRectangle viewport:aViewportRectangle
|
|
1443 |
"Adds aView to the views list of subviews and uses
|
|
1444 |
aWindowRectangle and aViewportRectangle to position it"
|
|
1445 |
|
|
1446 |
self addSubView:aView.
|
|
1447 |
aView window:aWindowRectangle.
|
|
1448 |
aView viewport:aViewportRectangle
|
|
1449 |
!
|
|
1450 |
|
|
1451 |
removeSubView:aView
|
|
1452 |
"remove a view from the collection of subviews"
|
|
1453 |
|
|
1454 |
subViews remove:aView ifAbsent:[nil].
|
|
1455 |
(subViews size == 0) ifTrue:[
|
|
1456 |
subViews := nil
|
|
1457 |
]
|
|
1458 |
! !
|
|
1459 |
|
|
1460 |
!View methodsFor:'ST-80 compatibility'!
|
|
1461 |
|
|
1462 |
on:aModel aspect:aspect change:change list:list menu:menu
|
|
1463 |
"ST-80 compatibility"
|
|
1464 |
|
|
1465 |
aspectSymbol := aspect.
|
|
1466 |
changeSymbol := change.
|
|
1467 |
menuSymbol := menu.
|
|
1468 |
self model:aModel
|
|
1469 |
!
|
|
1470 |
|
|
1471 |
sensor
|
20
|
1472 |
"return the views sensor"
|
|
1473 |
|
12
|
1474 |
windowGroup notNil ifTrue:[
|
|
1475 |
^ windowGroup sensor.
|
|
1476 |
].
|
|
1477 |
^ nil
|
0
|
1478 |
!
|
|
1479 |
|
|
1480 |
update
|
|
1481 |
^ self redraw
|
|
1482 |
!
|
|
1483 |
|
|
1484 |
update:aspect
|
|
1485 |
"an update request - should be redefined in subclasses"
|
|
1486 |
|
|
1487 |
^ self update
|
|
1488 |
!
|
|
1489 |
|
|
1490 |
update:aspect with:anObject
|
|
1491 |
"an update request - should be redefined in subclasses"
|
|
1492 |
|
|
1493 |
aspect == #rectangle ifTrue:[
|
|
1494 |
^ self update:#all
|
|
1495 |
].
|
|
1496 |
^ self update:aspect
|
|
1497 |
! !
|
|
1498 |
|
|
1499 |
!View methodsFor:'informing others of changes'!
|
|
1500 |
|
|
1501 |
originWillChange
|
|
1502 |
"this one is sent, just before viewOrigin changes -
|
|
1503 |
gives subclasses a chance to catch scrolls easily
|
|
1504 |
(for example to hide cursor before scroll)"
|
|
1505 |
|
|
1506 |
^ self
|
|
1507 |
!
|
|
1508 |
|
|
1509 |
originChangeAction:aBlock
|
|
1510 |
"set the action, aBlock to be evaluated whenever my orgin changes
|
|
1511 |
- to allow for scrollBars to track contents"
|
|
1512 |
|
|
1513 |
originChangeAction := aBlock
|
|
1514 |
!
|
|
1515 |
|
|
1516 |
originChanged:delta
|
|
1517 |
"this one is sent, after my origin changed -
|
|
1518 |
(for example to redraw cursor)"
|
|
1519 |
|
|
1520 |
originChangeAction notNil ifTrue:[originChangeAction value:self]
|
|
1521 |
!
|
|
1522 |
|
|
1523 |
contentsChangeAction:aBlock
|
|
1524 |
"set the action, aBlock to be evaluated whenever my contents changes
|
|
1525 |
- to allow for scrollBars to track contents"
|
|
1526 |
|
|
1527 |
contentsChangeAction := aBlock
|
|
1528 |
!
|
|
1529 |
|
|
1530 |
contentsChanged
|
|
1531 |
"this one is sent, whenever contents changes size -
|
|
1532 |
gives subclasses a chance to catch it (i.e. scrollbars etc)"
|
|
1533 |
|
|
1534 |
contentsChangeAction notNil ifTrue:[contentsChangeAction value:self]
|
|
1535 |
! !
|
|
1536 |
|
|
1537 |
!View methodsFor:'scrolling'!
|
|
1538 |
|
|
1539 |
widthForScrollBetween:firstLine and:lastLine
|
20
|
1540 |
"return the width in pixels for a scroll between firstLine and lastLine
|
0
|
1541 |
- return full width here since we do not know how wide contents is"
|
|
1542 |
|
|
1543 |
^ (width - margin - margin)
|
|
1544 |
!
|
|
1545 |
|
|
1546 |
scrollVerticalToPercent:percent
|
|
1547 |
"scroll to a position given in percent of total"
|
|
1548 |
|
|
1549 |
self scrollVerticalTo:
|
|
1550 |
((((self heightOfContents * percent) / 100.0) + 0.5) asInteger)
|
|
1551 |
!
|
|
1552 |
|
|
1553 |
scrollVerticalTo:aPixelOffset
|
|
1554 |
"change origin to make aPixelOffset be the top line"
|
|
1555 |
|
|
1556 |
|orgY|
|
|
1557 |
|
|
1558 |
orgY := viewOrigin y.
|
|
1559 |
|
|
1560 |
(aPixelOffset < orgY) ifTrue:[
|
|
1561 |
self scrollUp:(orgY - aPixelOffset)
|
|
1562 |
] ifFalse:[
|
|
1563 |
(aPixelOffset > orgY) ifTrue:[
|
|
1564 |
self scrollDown:(aPixelOffset - orgY)
|
|
1565 |
]
|
|
1566 |
]
|
|
1567 |
!
|
|
1568 |
|
|
1569 |
scrollHorizontalToPercent:percent
|
|
1570 |
"scroll to a position given in percent of total"
|
|
1571 |
|
|
1572 |
self scrollHorizontalTo:
|
|
1573 |
((((self widthOfContents * percent) / 100.0) + 0.5) asInteger)
|
|
1574 |
!
|
|
1575 |
|
|
1576 |
scrollHorizontalTo:aPixelOffset
|
|
1577 |
"change origin to make aPixelOffset be the left col"
|
|
1578 |
|
|
1579 |
|orgX|
|
|
1580 |
|
|
1581 |
orgX := viewOrigin x.
|
|
1582 |
|
|
1583 |
(aPixelOffset < orgX) ifTrue:[
|
|
1584 |
self scrollLeft:(orgX - aPixelOffset)
|
|
1585 |
] ifFalse:[
|
|
1586 |
(aPixelOffset > orgX) ifTrue:[
|
|
1587 |
self scrollRight:(aPixelOffset - orgX)
|
|
1588 |
]
|
|
1589 |
]
|
|
1590 |
!
|
|
1591 |
|
|
1592 |
scrollTo:aPixelOffset
|
|
1593 |
"only here for historic reasons - will vanish soon"
|
|
1594 |
|
|
1595 |
^ self scrollVerticalTo:aPixelOffset
|
|
1596 |
!
|
|
1597 |
|
|
1598 |
scrollToTop
|
|
1599 |
"move viewOrigin to top"
|
|
1600 |
|
|
1601 |
self scrollVerticalTo:0
|
|
1602 |
!
|
|
1603 |
|
2
|
1604 |
scrollToTopLeft
|
|
1605 |
"move viewOrigin to top/left"
|
|
1606 |
|
|
1607 |
self scrollVerticalTo:0.
|
|
1608 |
self scrollHorizontalTo:0
|
|
1609 |
!
|
|
1610 |
|
0
|
1611 |
scrollUp:nPixels
|
|
1612 |
"change origin to scroll up some pixels"
|
|
1613 |
|
|
1614 |
|count "{ Class:SmallInteger }"
|
|
1615 |
m2 "{ Class:SmallInteger }"
|
|
1616 |
w "{ Class:SmallInteger }"|
|
|
1617 |
|
|
1618 |
count := nPixels.
|
|
1619 |
(count > viewOrigin y) ifTrue:[
|
|
1620 |
count := viewOrigin y
|
|
1621 |
].
|
|
1622 |
(count <= 0) ifTrue:[^ self].
|
|
1623 |
|
|
1624 |
self originWillChange.
|
|
1625 |
viewOrigin := viewOrigin x @ (viewOrigin y - count).
|
|
1626 |
|
|
1627 |
(count >= self innerHeight) ifTrue:[
|
|
1628 |
self redraw.
|
|
1629 |
self originChanged:(0 @ count negated)
|
|
1630 |
] ifFalse:[
|
|
1631 |
w := self widthForScrollBetween:(viewOrigin y)
|
|
1632 |
and:(viewOrigin y + count).
|
|
1633 |
m2 := margin * 2.
|
|
1634 |
w := w min:(width - m2).
|
|
1635 |
|
|
1636 |
"
|
|
1637 |
super function:#copy.
|
|
1638 |
super foreground:White.
|
|
1639 |
"
|
|
1640 |
self copyFrom:self x:margin y:margin
|
|
1641 |
toX:margin y:(count + margin)
|
|
1642 |
width:w
|
|
1643 |
height:(height - m2 - count).
|
|
1644 |
self redrawX:margin y:margin
|
|
1645 |
width:(width - m2)
|
|
1646 |
height:count.
|
|
1647 |
|
|
1648 |
self originChanged:(0 @ count negated).
|
|
1649 |
self waitForExpose
|
|
1650 |
]
|
|
1651 |
!
|
|
1652 |
|
|
1653 |
scrollUp
|
|
1654 |
"scroll up by some amount
|
|
1655 |
- question is how much is a good default here"
|
|
1656 |
|
|
1657 |
self scrollUp:(device verticalPixelPerMillimeter * 20) asInteger
|
|
1658 |
!
|
|
1659 |
|
|
1660 |
scrollDown:nPixels
|
|
1661 |
"change origin to scroll down some pixels"
|
|
1662 |
|
|
1663 |
|count "{ Class:SmallInteger }"
|
|
1664 |
m2 "{ Class:SmallInteger }"
|
|
1665 |
w "{ Class:SmallInteger }"
|
|
1666 |
hCont "{ Class:SmallInteger }"
|
|
1667 |
ih "{ Class:SmallInteger }"|
|
|
1668 |
|
|
1669 |
count := nPixels.
|
|
1670 |
hCont := self heightOfContents.
|
|
1671 |
ih := self innerHeight.
|
|
1672 |
|
|
1673 |
((viewOrigin y + nPixels + ih) > hCont) ifTrue:[
|
|
1674 |
count := hCont - viewOrigin y - ih
|
|
1675 |
].
|
|
1676 |
(count <= 0) ifTrue:[^ self].
|
|
1677 |
|
|
1678 |
self originWillChange.
|
|
1679 |
viewOrigin := viewOrigin x @ (viewOrigin y + count).
|
|
1680 |
|
|
1681 |
(count >= ih) ifTrue:[
|
|
1682 |
self redraw.
|
|
1683 |
self originChanged:(0 @ count)
|
|
1684 |
] ifFalse:[
|
|
1685 |
m2 := margin * 2.
|
|
1686 |
w := self widthForScrollBetween:(viewOrigin y)
|
|
1687 |
and:(viewOrigin y + count).
|
|
1688 |
w := w min:(width - m2).
|
|
1689 |
|
|
1690 |
"
|
|
1691 |
super function:#copy.
|
|
1692 |
super foreground:White.
|
|
1693 |
"
|
|
1694 |
self copyFrom:self x:margin y:(count + margin)
|
|
1695 |
toX:margin y:margin
|
|
1696 |
width:w
|
|
1697 |
height:(height - m2 - count).
|
|
1698 |
|
|
1699 |
self redrawX:margin y:(height - margin - count)
|
|
1700 |
width:(width - m2) height:count.
|
|
1701 |
|
|
1702 |
self originChanged:(0 @ count).
|
|
1703 |
self waitForExpose
|
|
1704 |
]
|
|
1705 |
!
|
|
1706 |
|
|
1707 |
scrollDown
|
|
1708 |
"scroll down by some amount
|
|
1709 |
- question is how much is a good default here"
|
|
1710 |
|
|
1711 |
self scrollDown:(device verticalPixelPerMillimeter * 20) asInteger
|
|
1712 |
!
|
|
1713 |
|
|
1714 |
scrollLeft:nPixels
|
|
1715 |
"change origin to scroll left some pixels"
|
|
1716 |
|
|
1717 |
|count "{ Class:SmallInteger }"
|
|
1718 |
m2 "{ Class:SmallInteger }"
|
|
1719 |
h "{ Class:SmallInteger }"|
|
|
1720 |
|
|
1721 |
count := nPixels.
|
|
1722 |
(count > viewOrigin x) ifTrue:[
|
|
1723 |
count := viewOrigin x
|
|
1724 |
].
|
|
1725 |
(count <= 0) ifTrue:[^ self].
|
|
1726 |
|
|
1727 |
self originWillChange.
|
|
1728 |
viewOrigin := (viewOrigin x - count) @ viewOrigin y.
|
|
1729 |
|
|
1730 |
(count >= self innerWidth) ifTrue:[
|
|
1731 |
self redraw.
|
|
1732 |
self originChanged:(count negated @ 0)
|
|
1733 |
] ifFalse:[
|
|
1734 |
m2 := margin * 2.
|
|
1735 |
h := (height - m2).
|
|
1736 |
|
|
1737 |
"
|
|
1738 |
super function:#copy.
|
|
1739 |
super foreground:White.
|
|
1740 |
"
|
|
1741 |
self copyFrom:self x:margin y:margin
|
|
1742 |
toX:(count + margin) y:margin
|
|
1743 |
width:(width - m2 - count)
|
|
1744 |
height:h.
|
|
1745 |
|
|
1746 |
self redrawX:margin y:margin
|
|
1747 |
width:count
|
|
1748 |
height:(height - m2).
|
|
1749 |
|
|
1750 |
self originChanged:(count negated @ 0).
|
|
1751 |
self waitForExpose
|
|
1752 |
]
|
|
1753 |
!
|
|
1754 |
|
|
1755 |
scrollLeft
|
|
1756 |
"scroll left by some amount
|
|
1757 |
- question is how much is a good default here"
|
|
1758 |
|
|
1759 |
self scrollLeft:(device horizontalPixelPerMillimeter * 20) asInteger
|
|
1760 |
!
|
|
1761 |
|
|
1762 |
scrollRight:nPixels
|
|
1763 |
"change origin to scroll right some pixels"
|
|
1764 |
|
|
1765 |
|count "{ Class:SmallInteger }"
|
|
1766 |
m2 "{ Class:SmallInteger }"
|
|
1767 |
h "{ Class:SmallInteger }"
|
|
1768 |
wCont "{ Class:SmallInteger }"
|
|
1769 |
iw "{ Class:SmallInteger }"|
|
|
1770 |
|
|
1771 |
count := nPixels.
|
|
1772 |
wCont := self widthOfContents.
|
|
1773 |
iw := self innerWidth.
|
|
1774 |
|
|
1775 |
((viewOrigin x + nPixels + iw) > wCont) ifTrue:[
|
|
1776 |
count := wCont - viewOrigin x - iw
|
|
1777 |
].
|
|
1778 |
(count <= 0) ifTrue:[^ self].
|
|
1779 |
|
|
1780 |
self originWillChange.
|
|
1781 |
viewOrigin := (viewOrigin x + count) @ viewOrigin y.
|
|
1782 |
|
|
1783 |
(count >= iw) ifTrue:[
|
|
1784 |
self redraw.
|
|
1785 |
self originChanged:(count @ 0)
|
|
1786 |
] ifFalse:[
|
|
1787 |
m2 := margin * 2.
|
|
1788 |
h := (height - m2).
|
|
1789 |
|
|
1790 |
"
|
|
1791 |
super function:#copy.
|
|
1792 |
super foreground:White.
|
|
1793 |
"
|
|
1794 |
self copyFrom:self x:(count + margin) y:margin
|
|
1795 |
toX:margin y:margin
|
|
1796 |
width:(width - m2 - count)
|
|
1797 |
height:h.
|
|
1798 |
|
|
1799 |
self redrawX:(width - margin - count) y:margin
|
|
1800 |
width:count height:(height - m2).
|
|
1801 |
|
|
1802 |
self originChanged:(count @ 0).
|
|
1803 |
self waitForExpose
|
|
1804 |
]
|
|
1805 |
!
|
|
1806 |
|
|
1807 |
scrollRight
|
|
1808 |
"scroll right by some amount
|
|
1809 |
- question is how much is a good default here"
|
|
1810 |
|
|
1811 |
self scrollRight:(device horizontalPixelPerMillimeter * 20) asInteger
|
|
1812 |
! !
|
|
1813 |
|
|
1814 |
!View methodsFor:'private'!
|
|
1815 |
|
|
1816 |
pixelExtent:extent
|
|
1817 |
"set the views extent in pixels"
|
|
1818 |
|
15
|
1819 |
self pixelOrigin:(left @ top) extent:extent
|
|
1820 |
!
|
|
1821 |
|
|
1822 |
XXpixelExtent:extent
|
|
1823 |
"set the views extent in pixels"
|
|
1824 |
|
0
|
1825 |
|newWidth newHeight how mustRedrawBottomEdge mustRedrawRightEdge|
|
|
1826 |
|
|
1827 |
newWidth := extent x.
|
|
1828 |
newHeight := extent y.
|
|
1829 |
((newWidth ~~ width) or:[newHeight ~~ height]) ifTrue:[
|
|
1830 |
"shown "drawableId notNil"" ifTrue:[ "23-feb-93"
|
|
1831 |
((newHeight <= height) and:[newWidth <= width]) ifTrue:[
|
|
1832 |
how := #smaller
|
|
1833 |
].
|
|
1834 |
|
|
1835 |
mustRedrawBottomEdge := (level ~~ 0) and:[newHeight < height].
|
|
1836 |
mustRedrawRightEdge := (level ~~ 0) and:[newWidth < width].
|
|
1837 |
|
|
1838 |
(level ~~ 0) ifTrue:[
|
|
1839 |
"clear the old edges"
|
|
1840 |
|
|
1841 |
newWidth > width ifTrue:[
|
|
1842 |
self clipRect:nil.
|
|
1843 |
self paint:viewBackground.
|
|
1844 |
self fillRectangleX:(width - margin)
|
|
1845 |
y:0
|
|
1846 |
width:margin
|
|
1847 |
height:height
|
|
1848 |
].
|
|
1849 |
newHeight > height ifTrue:[
|
|
1850 |
self clipRect:nil.
|
|
1851 |
self paint:viewBackground.
|
|
1852 |
self fillRectangleX:0
|
|
1853 |
y:(height - margin)
|
|
1854 |
width:width
|
|
1855 |
height:margin
|
|
1856 |
]
|
|
1857 |
]
|
|
1858 |
].
|
|
1859 |
|
|
1860 |
width := newWidth.
|
|
1861 |
height := newHeight.
|
|
1862 |
|
|
1863 |
"shown "drawableId notNil"" ifTrue:[ "23-feb-93"
|
|
1864 |
self setInnerClip.
|
|
1865 |
|
|
1866 |
(how == #smaller) ifTrue:[
|
|
1867 |
"if view becomes smaller, send sizeChanged first"
|
12
|
1868 |
self sizeChanged:how
|
0
|
1869 |
].
|
|
1870 |
|
|
1871 |
"have to tell X, when extent of view is changed"
|
|
1872 |
device resizeWindow:drawableId width:width height:height.
|
|
1873 |
|
|
1874 |
"if view becomes bigger, send sizeChanged after"
|
|
1875 |
(how ~~ #smaller) ifTrue:[
|
12
|
1876 |
self sizeChanged:how
|
0
|
1877 |
].
|
|
1878 |
|
|
1879 |
(mustRedrawBottomEdge or:[mustRedrawRightEdge]) ifTrue:[
|
|
1880 |
self clipRect:nil.
|
|
1881 |
mustRedrawBottomEdge ifTrue:[
|
|
1882 |
self drawBottomEdge
|
|
1883 |
].
|
|
1884 |
mustRedrawRightEdge ifTrue:[
|
|
1885 |
self drawRightEdge
|
|
1886 |
].
|
|
1887 |
self clipRect:innerClipRect
|
|
1888 |
]
|
|
1889 |
] ifFalse:[
|
|
1890 |
"otherwise memorize the need for a sizeChanged message"
|
|
1891 |
extentChanged := true
|
|
1892 |
]
|
|
1893 |
]
|
|
1894 |
!
|
|
1895 |
|
|
1896 |
pixelOrigin:origin
|
|
1897 |
"set the views origin in pixels"
|
|
1898 |
|
|
1899 |
|newLeft newTop|
|
|
1900 |
|
|
1901 |
newLeft := origin x.
|
|
1902 |
newTop := origin y.
|
|
1903 |
((newTop ~~ top) or:[newLeft ~~ left]) ifTrue:[
|
|
1904 |
top := newTop.
|
|
1905 |
left := newLeft.
|
|
1906 |
drawableId notNil ifTrue:[
|
|
1907 |
"have to tell X, when origin of view is changed"
|
|
1908 |
device moveWindow:drawableId x:left y:top
|
|
1909 |
].
|
|
1910 |
realized ifFalse:[
|
|
1911 |
originChanged := true
|
|
1912 |
]
|
|
1913 |
]
|
|
1914 |
!
|
|
1915 |
|
|
1916 |
pixelCorner:corner
|
|
1917 |
"set the views corner in pixels"
|
|
1918 |
|
|
1919 |
|newWidth newHeight|
|
|
1920 |
|
|
1921 |
newWidth := corner x - left.
|
|
1922 |
newHeight := corner y - top.
|
15
|
1923 |
" old:
|
0
|
1924 |
self pixelExtent:(newWidth @ newHeight)
|
15
|
1925 |
"
|
|
1926 |
self pixelOrigin:(left @ top) extent:(newWidth @ newHeight)
|
0
|
1927 |
!
|
|
1928 |
|
|
1929 |
pixelOrigin:origin corner:corner
|
|
1930 |
"set the views origin and extent in pixels"
|
|
1931 |
|
|
1932 |
|newWidth newHeight|
|
|
1933 |
|
|
1934 |
newWidth := corner x - origin x.
|
|
1935 |
newHeight := corner y - origin y.
|
|
1936 |
self pixelOrigin:origin extent:(newWidth @ newHeight)
|
|
1937 |
!
|
|
1938 |
|
|
1939 |
pixelOrigin:origin extent:extent
|
|
1940 |
"set the views origin and extent in pixels"
|
|
1941 |
|
15
|
1942 |
|newLeft newTop newWidth newHeight how
|
|
1943 |
mustRedrawBottomEdge mustRedrawRightEdge mustRepaintBottom
|
|
1944 |
mustRepaintRight sameOrigin oldWidth oldHeight|
|
0
|
1945 |
|
|
1946 |
newLeft := origin x.
|
|
1947 |
newTop := origin y.
|
15
|
1948 |
sameOrigin := ((newTop == top) and:[newLeft == left]).
|
|
1949 |
|
0
|
1950 |
newWidth := extent x.
|
|
1951 |
newHeight := extent y.
|
|
1952 |
((newWidth == width) and:[newHeight == height]) ifTrue:[
|
15
|
1953 |
sameOrigin ifTrue:[^ self].
|
0
|
1954 |
^ self pixelOrigin:origin
|
|
1955 |
].
|
|
1956 |
top := newTop.
|
|
1957 |
left := newLeft.
|
|
1958 |
|
|
1959 |
mustRedrawBottomEdge := (level ~~ 0) and:[newHeight < height].
|
|
1960 |
mustRedrawRightEdge := (level ~~ 0) and:[newWidth < width].
|
|
1961 |
|
|
1962 |
((newHeight <= height) and:[newWidth <= width]) ifTrue:[
|
|
1963 |
how := #smaller
|
|
1964 |
].
|
|
1965 |
|
|
1966 |
"shown "drawableId notNil"" ifTrue:[ "23-feb-93"
|
15
|
1967 |
mustRepaintRight := false.
|
|
1968 |
mustRepaintBottom := false.
|
0
|
1969 |
(level ~~ 0) ifTrue:[
|
|
1970 |
"clear the old edges"
|
|
1971 |
|
|
1972 |
newWidth > width ifTrue:[
|
|
1973 |
self clipRect:nil.
|
|
1974 |
self paint:viewBackground.
|
|
1975 |
self fillRectangleX:(width - margin)
|
|
1976 |
y:0
|
|
1977 |
width:margin
|
15
|
1978 |
height:height.
|
|
1979 |
mustRepaintRight := true.
|
|
1980 |
oldWidth := width
|
0
|
1981 |
].
|
|
1982 |
newHeight > height ifTrue:[
|
|
1983 |
self clipRect:nil.
|
|
1984 |
self paint:viewBackground.
|
|
1985 |
self fillRectangleX:0
|
|
1986 |
y:(height - margin)
|
|
1987 |
width:width
|
15
|
1988 |
height:margin.
|
|
1989 |
mustRepaintBottom := true.
|
|
1990 |
oldHeight := height
|
0
|
1991 |
]
|
|
1992 |
].
|
|
1993 |
|
15
|
1994 |
width := newWidth.
|
|
1995 |
height := newHeight.
|
|
1996 |
|
0
|
1997 |
self setInnerClip.
|
|
1998 |
|
|
1999 |
"if view becomes smaller, send sizeChanged first"
|
|
2000 |
(how == #smaller) ifTrue:[
|
12
|
2001 |
self sizeChanged:how
|
0
|
2002 |
].
|
|
2003 |
|
|
2004 |
"have to tell X, when extent of view is changed"
|
15
|
2005 |
sameOrigin ifTrue:[
|
0
|
2006 |
device resizeWindow:drawableId width:width height:height.
|
|
2007 |
] ifFalse:[
|
15
|
2008 |
"claus: some xservers seem to do better when resizing
|
|
2009 |
first ...."
|
|
2010 |
"
|
|
2011 |
(how == #smaller) ifTrue:[
|
|
2012 |
device resizeWindow:drawableId width:width height:height.
|
|
2013 |
device moveWindow:drawableId x:left y:top
|
|
2014 |
] ifFalse:[
|
|
2015 |
device moveResizeWindow:drawableId x:left y:top width:width height:height
|
|
2016 |
].
|
|
2017 |
"
|
|
2018 |
device moveResizeWindow:drawableId x:left y:top
|
|
2019 |
width:width height:height.
|
|
2020 |
" "
|
0
|
2021 |
].
|
|
2022 |
|
|
2023 |
"if view becomes bigger, send sizeChanged after"
|
|
2024 |
(how ~~ #smaller) ifTrue:[
|
12
|
2025 |
self sizeChanged:how
|
0
|
2026 |
].
|
15
|
2027 |
|
0
|
2028 |
(mustRedrawBottomEdge or:[mustRedrawRightEdge]) ifTrue:[
|
|
2029 |
self clipRect:nil.
|
|
2030 |
mustRedrawBottomEdge ifTrue:[
|
|
2031 |
self drawBottomEdge
|
|
2032 |
].
|
|
2033 |
mustRedrawRightEdge ifTrue:[
|
|
2034 |
self drawRightEdge
|
|
2035 |
].
|
|
2036 |
self clipRect:innerClipRect
|
15
|
2037 |
].
|
|
2038 |
mustRepaintRight ifTrue:[
|
|
2039 |
self redrawX:(oldWidth - margin)
|
|
2040 |
y:0
|
|
2041 |
width:margin
|
|
2042 |
height:height.
|
|
2043 |
].
|
|
2044 |
mustRepaintBottom ifTrue:[
|
|
2045 |
self redrawX:0
|
|
2046 |
y:(oldHeight - margin)
|
|
2047 |
width:width
|
|
2048 |
height:margin.
|
|
2049 |
].
|
0
|
2050 |
] ifFalse:[
|
|
2051 |
"otherwise memorize the need for a sizeChanged message"
|
15
|
2052 |
|
|
2053 |
width := newWidth.
|
|
2054 |
height := newHeight.
|
|
2055 |
sameOrigin ifFalse:[
|
|
2056 |
originChanged := true.
|
|
2057 |
].
|
0
|
2058 |
extentChanged := true
|
|
2059 |
]
|
|
2060 |
!
|
|
2061 |
|
|
2062 |
pointFromRelativePoint:relativePoint
|
|
2063 |
"given relative point, compute absolute point (in pixels)"
|
|
2064 |
|
|
2065 |
|newX newY rel inRect|
|
|
2066 |
|
|
2067 |
superView isNil ifTrue:[^ nil].
|
|
2068 |
inRect := superView viewRectangle.
|
|
2069 |
|
|
2070 |
rel := relativePoint x.
|
|
2071 |
(rel isMemberOf:Float) ifTrue:[
|
|
2072 |
newX := (rel * (inRect width + (2 * borderWidth))) asInteger + inRect left
|
|
2073 |
] ifFalse:[
|
|
2074 |
newX := rel
|
|
2075 |
].
|
|
2076 |
rel := relativePoint y.
|
|
2077 |
(rel isMemberOf:Float) ifTrue:[
|
|
2078 |
newY := (rel * (inRect height + (2 * borderWidth))) asInteger + inRect top
|
|
2079 |
] ifFalse:[
|
|
2080 |
newY := rel
|
|
2081 |
].
|
|
2082 |
^ (newX @ newY)
|
|
2083 |
!
|
|
2084 |
|
|
2085 |
originFromRelativeOrigin
|
|
2086 |
"compute pixel origin from relativeOrigin"
|
|
2087 |
|
|
2088 |
|newOrigin newX newY rel inRect bw2|
|
|
2089 |
|
|
2090 |
superView isNil ifTrue:[^ nil].
|
|
2091 |
|
|
2092 |
inRect := superView viewRectangle.
|
|
2093 |
bw2 := borderWidth * 2.
|
|
2094 |
rel := relativeOrigin x.
|
|
2095 |
(rel isMemberOf:Float) ifTrue:[
|
2
|
2096 |
newX := (rel * (inRect width + borderWidth "bw2")) asInteger + inRect left
|
0
|
2097 |
] ifFalse:[
|
|
2098 |
newX := rel
|
|
2099 |
].
|
|
2100 |
rel := relativeOrigin y.
|
|
2101 |
(rel isMemberOf:Float) ifTrue:[
|
2
|
2102 |
newY := (rel * (inRect height + borderWidth "bw2")) asInteger + inRect top
|
0
|
2103 |
] ifFalse:[
|
|
2104 |
newY := rel
|
|
2105 |
].
|
|
2106 |
newOrigin := (newX @ newY).
|
|
2107 |
|
|
2108 |
(borderWidth ~~ 0) ifTrue:[
|
|
2109 |
(relativeOrigin x isMemberOf:Float) ifTrue:[
|
|
2110 |
newOrigin x:(newOrigin x - borderWidth)
|
|
2111 |
].
|
|
2112 |
(relativeOrigin y isMemberOf:Float) ifTrue:[
|
|
2113 |
newOrigin y:(newOrigin y - borderWidth)
|
|
2114 |
]
|
|
2115 |
].
|
|
2116 |
^ newOrigin
|
|
2117 |
!
|
|
2118 |
|
|
2119 |
cornerFromRelativeCorner
|
|
2120 |
"compute pixel corner from relativeCorner"
|
|
2121 |
|
|
2122 |
|newCorner newX newY rel inRect bw2|
|
|
2123 |
|
|
2124 |
superView isNil ifTrue:[^ nil].
|
|
2125 |
|
|
2126 |
inRect := superView viewRectangle.
|
|
2127 |
bw2 := borderWidth * 2.
|
|
2128 |
rel := relativeCorner x.
|
|
2129 |
(rel isMemberOf:Float) ifTrue:[
|
|
2130 |
newX := (rel * (inRect width" + bw2")) asInteger "+ inRect left"
|
|
2131 |
] ifFalse:[
|
|
2132 |
newX := rel
|
|
2133 |
].
|
|
2134 |
rel := relativeCorner y.
|
|
2135 |
(rel isMemberOf:Float) ifTrue:[
|
|
2136 |
newY := (rel * (inRect height" + bw2")) asInteger "+ inRect top"
|
|
2137 |
] ifFalse:[
|
|
2138 |
newY := rel
|
|
2139 |
].
|
|
2140 |
newCorner := (newX @ newY).
|
|
2141 |
|
|
2142 |
(borderWidth ~~ 0) ifTrue:[
|
|
2143 |
(relativeCorner x isMemberOf:Float) ifTrue:[
|
|
2144 |
newCorner x:(newCorner x - borderWidth)
|
|
2145 |
].
|
|
2146 |
(relativeCorner y isMemberOf:Float) ifTrue:[
|
|
2147 |
newCorner y:(newCorner y - borderWidth)
|
|
2148 |
]
|
|
2149 |
].
|
|
2150 |
^ newCorner
|
|
2151 |
!
|
|
2152 |
|
|
2153 |
extentFromRelativeExtent
|
|
2154 |
"compute pixel extent from relativeExtent"
|
|
2155 |
|
|
2156 |
|newExtent newX newY rel inRect bw2|
|
|
2157 |
|
|
2158 |
superView isNil ifTrue:[^ nil].
|
|
2159 |
|
|
2160 |
inRect := superView viewRectangle.
|
|
2161 |
bw2 := borderWidth * 2.
|
|
2162 |
rel := relativeExtent x.
|
|
2163 |
(rel isMemberOf:Float) ifTrue:[
|
|
2164 |
newX := (rel * (inRect width + bw2)) asInteger + inRect left
|
|
2165 |
] ifFalse:[
|
|
2166 |
newX := rel
|
|
2167 |
].
|
|
2168 |
rel := relativeExtent y.
|
|
2169 |
(rel isMemberOf:Float) ifTrue:[
|
|
2170 |
newY := (rel * (inRect height + bw2)) asInteger + inRect top
|
|
2171 |
] ifFalse:[
|
|
2172 |
newY := rel
|
|
2173 |
].
|
|
2174 |
newExtent := (newX @ newY).
|
|
2175 |
|
|
2176 |
(borderWidth ~~ 0) ifTrue:[
|
|
2177 |
(relativeExtent x isMemberOf:Float) ifTrue:[
|
|
2178 |
newExtent x:(newExtent x - (1 * borderWidth))
|
|
2179 |
].
|
|
2180 |
(relativeExtent y isMemberOf:Float) ifTrue:[
|
|
2181 |
newExtent y:(newExtent y - (1 * borderWidth))
|
|
2182 |
]
|
|
2183 |
].
|
|
2184 |
^ newExtent
|
|
2185 |
!
|
|
2186 |
|
|
2187 |
dimensionFromViewport
|
|
2188 |
"define my origin/extend from viewport"
|
|
2189 |
|
|
2190 |
|relW relH relX relY winW winH org ext|
|
|
2191 |
|
|
2192 |
superView notNil ifTrue:[
|
|
2193 |
superView window isNil ifTrue:[
|
|
2194 |
"
|
|
2195 |
v := superView.
|
|
2196 |
(v notNil and:[v window isNil]) whileTrue:[
|
|
2197 |
v := v superview
|
|
2198 |
].
|
|
2199 |
v notNil ifTrue:[
|
|
2200 |
w := v window
|
|
2201 |
].
|
|
2202 |
"
|
|
2203 |
"
|
|
2204 |
winW := 1.
|
|
2205 |
winH := 1
|
|
2206 |
"
|
|
2207 |
winW := superView width.
|
|
2208 |
winH := superView height.
|
|
2209 |
|
|
2210 |
] ifFalse:[
|
|
2211 |
winW := superView window width.
|
|
2212 |
winH := superView window height
|
|
2213 |
].
|
|
2214 |
relW := (viewport width / winW) asFloat.
|
|
2215 |
relH := (viewport height / winH) asFloat.
|
|
2216 |
relX := (viewport left / winW) asFloat.
|
|
2217 |
relY := (viewport top / winH) asFloat.
|
|
2218 |
relativeOrigin := (relX @ relY).
|
|
2219 |
org := self originFromRelativeOrigin.
|
|
2220 |
relativeOrigin := nil.
|
|
2221 |
|
|
2222 |
relativeExtent := (relW @ relH).
|
|
2223 |
ext := self extentFromRelativeExtent.
|
|
2224 |
relativeExtent := nil.
|
|
2225 |
|
|
2226 |
self pixelOrigin:org extent:ext.
|
|
2227 |
]
|
|
2228 |
!
|
|
2229 |
|
|
2230 |
computeInnerClip
|
|
2231 |
|m2|
|
|
2232 |
|
|
2233 |
(margin ~~ 0) ifTrue:[
|
|
2234 |
m2 := margin + margin.
|
|
2235 |
innerClipRect := Rectangle left:margin top:margin
|
|
2236 |
width:(width - m2) height:(height - m2)
|
|
2237 |
] ifFalse:[
|
|
2238 |
innerClipRect := nil
|
|
2239 |
]
|
|
2240 |
!
|
|
2241 |
|
|
2242 |
setInnerClip
|
|
2243 |
|m2|
|
|
2244 |
|
|
2245 |
(margin ~~ 0) ifTrue:[
|
|
2246 |
m2 := margin + margin.
|
|
2247 |
innerClipRect := Rectangle left:margin top:margin
|
|
2248 |
width:(width - m2)
|
|
2249 |
height:(height - m2)
|
|
2250 |
] ifFalse:[
|
|
2251 |
innerClipRect := nil
|
|
2252 |
].
|
|
2253 |
self clipRect:innerClipRect
|
|
2254 |
! !
|
|
2255 |
|
|
2256 |
!View methodsFor:'realization'!
|
|
2257 |
|
|
2258 |
create
|
|
2259 |
"create (i.e. tell X about me)
|
|
2260 |
this is kind of stupid - creation means XCreateWindow;
|
|
2261 |
realizing means XMapWindow"
|
|
2262 |
|
|
2263 |
drawableId isNil ifTrue:[
|
|
2264 |
"make certain, superview is created also"
|
|
2265 |
|
|
2266 |
superView notNil ifTrue:[
|
|
2267 |
superView id isNil ifTrue:[
|
|
2268 |
superView create
|
12
|
2269 |
].
|
|
2270 |
|
|
2271 |
"and put my controller into the superviews controller list"
|
|
2272 |
controller notNil ifTrue:[
|
|
2273 |
superView controller notNil ifTrue:[
|
|
2274 |
controller manager:(superView controller manager)
|
|
2275 |
]
|
0
|
2276 |
]
|
|
2277 |
].
|
|
2278 |
|
|
2279 |
"associate cursor/colors to device"
|
|
2280 |
|
|
2281 |
viewBackground := viewBackground on:device.
|
|
2282 |
borderColor := borderColor on:device.
|
|
2283 |
shadowColor := shadowColor on:device.
|
|
2284 |
lightColor := lightColor on:device.
|
|
2285 |
cursor := cursor on:device.
|
|
2286 |
|
|
2287 |
drawableId := device createWindowFor:self
|
|
2288 |
left:left top:top
|
|
2289 |
width:width height:height.
|
|
2290 |
|
|
2291 |
extentChanged := false.
|
|
2292 |
originChanged := false.
|
|
2293 |
|
|
2294 |
borderShape notNil ifTrue:[
|
|
2295 |
device setWindowBorderShape:(borderShape id) in:drawableId
|
|
2296 |
].
|
|
2297 |
viewShape notNil ifTrue:[
|
|
2298 |
device setWindowShape:(viewShape id) in:drawableId
|
|
2299 |
].
|
2
|
2300 |
(backed notNil and:[backed ~~ false]) ifTrue:[
|
0
|
2301 |
device setBackingStore:backed in:drawableId
|
|
2302 |
].
|
|
2303 |
saveUnder ifTrue:[
|
|
2304 |
device setSaveUnder:true in:drawableId
|
|
2305 |
].
|
|
2306 |
|
|
2307 |
font := font on:device.
|
12
|
2308 |
|
0
|
2309 |
self initializeMiddleButtonMenu.
|
|
2310 |
self initEvents.
|
|
2311 |
]
|
|
2312 |
!
|
|
2313 |
|
|
2314 |
createWithAllSubViews
|
|
2315 |
"create, then create all subviews"
|
|
2316 |
|
|
2317 |
drawableId isNil ifTrue:[self create].
|
|
2318 |
subViews notNil ifTrue:[
|
|
2319 |
subViews do:[:subView | subView createWithAllSubViews]
|
|
2320 |
]
|
|
2321 |
!
|
|
2322 |
|
|
2323 |
initializeMiddleButtonMenu
|
|
2324 |
"a place to initialize menu - this one is sent once when the view is
|
|
2325 |
first created; usually redefined in subclasses; default here is no menu"
|
|
2326 |
|
|
2327 |
^ self
|
|
2328 |
!
|
|
2329 |
|
|
2330 |
fixSize
|
|
2331 |
"adjust size of window according to either relative/abs or
|
|
2332 |
block extent; also set origin"
|
|
2333 |
|
|
2334 |
window notNil ifTrue:[
|
|
2335 |
^ self superViewChangedSize
|
|
2336 |
].
|
|
2337 |
|
|
2338 |
"if the extent is not the one we created the window with ..."
|
|
2339 |
extentChanged ifTrue:[
|
12
|
2340 |
self sizeChanged:nil.
|
0
|
2341 |
extentChanged := false
|
|
2342 |
].
|
|
2343 |
|
|
2344 |
originChanged ifTrue:[
|
|
2345 |
originRule notNil ifTrue:[
|
|
2346 |
self pixelOrigin:(originRule value)
|
|
2347 |
] ifFalse:[
|
|
2348 |
relativeOrigin notNil ifTrue:[
|
|
2349 |
self originFromRelativeOrigin
|
|
2350 |
]
|
|
2351 |
].
|
|
2352 |
originChanged := false
|
|
2353 |
]
|
|
2354 |
!
|
|
2355 |
|
|
2356 |
realize
|
|
2357 |
"realize - make visible;
|
|
2358 |
realizing is done very late (after layout is fixed) to avoid
|
|
2359 |
visible rearranging of windows on the screen"
|
|
2360 |
|
|
2361 |
drawableId isNil ifTrue:[
|
|
2362 |
self create.
|
12
|
2363 |
|
0
|
2364 |
"if it is the first realize (which means a create),
|
|
2365 |
force sizechange messages"
|
|
2366 |
extentChanged := true.
|
|
2367 |
originChanged := true
|
|
2368 |
].
|
|
2369 |
|
12
|
2370 |
"put myself into superviews windowgroup"
|
|
2371 |
superView notNil ifTrue:[
|
|
2372 |
windowGroup notNil ifTrue:[
|
|
2373 |
'oops - wgroup change on realize' printNewline.
|
|
2374 |
windowGroup removeView:self
|
|
2375 |
].
|
|
2376 |
windowGroup := superView windowGroup.
|
|
2377 |
windowGroup notNil ifTrue:[
|
|
2378 |
windowGroup addView:self.
|
|
2379 |
]
|
|
2380 |
].
|
|
2381 |
|
0
|
2382 |
hidden ifTrue:[
|
|
2383 |
^ self
|
|
2384 |
].
|
|
2385 |
|
|
2386 |
realized ifFalse:[
|
|
2387 |
(originChanged or:[extentChanged]) ifTrue:[self fixSize].
|
|
2388 |
subViews notNil ifTrue:[
|
|
2389 |
subViews do:[:subView |
|
|
2390 |
subView realize
|
|
2391 |
]
|
|
2392 |
].
|
|
2393 |
self setInnerClip.
|
|
2394 |
|
|
2395 |
"and make it visible"
|
|
2396 |
device mapWindow:drawableId.
|
|
2397 |
realized := true
|
|
2398 |
]
|
|
2399 |
!
|
|
2400 |
|
|
2401 |
rerealize
|
|
2402 |
"rerealize at old position"
|
|
2403 |
|
|
2404 |
device mapWindow:drawableId iconified:false
|
|
2405 |
atX:left y:top
|
|
2406 |
width:width height:height
|
|
2407 |
!
|
|
2408 |
|
|
2409 |
destroy
|
|
2410 |
"unrealize & destroy - make me invisible, destroy subviews then
|
|
2411 |
make me unknown to the device"
|
|
2412 |
|
|
2413 |
realized ifTrue:[
|
|
2414 |
self unrealize.
|
12
|
2415 |
"make it go away immediately
|
|
2416 |
- also, this hides the subview killing"
|
|
2417 |
"
|
|
2418 |
device synchronizeOutput.
|
|
2419 |
"
|
0
|
2420 |
].
|
|
2421 |
|
|
2422 |
model notNil ifTrue:[
|
|
2423 |
model removeDependent:self
|
|
2424 |
].
|
|
2425 |
controller := nil.
|
|
2426 |
|
12
|
2427 |
subViews notNil ifTrue:[
|
|
2428 |
"stupid: destroy removes itself from the subveiws list
|
|
2429 |
- therefore we have to loop over a copy here"
|
|
2430 |
|
|
2431 |
subViews copy do:[:aView |
|
|
2432 |
aView notNil ifTrue:[aView destroy]
|
|
2433 |
]
|
0
|
2434 |
].
|
|
2435 |
superView notNil ifTrue:[
|
|
2436 |
superView removeSubView:self.
|
|
2437 |
superView := nil
|
|
2438 |
].
|
12
|
2439 |
super destroy.
|
|
2440 |
|
|
2441 |
windowGroup notNil ifTrue:[
|
|
2442 |
windowGroup removeView:self
|
|
2443 |
].
|
0
|
2444 |
!
|
|
2445 |
|
|
2446 |
unrealize
|
|
2447 |
"hide me"
|
|
2448 |
|
|
2449 |
realized ifTrue:[
|
|
2450 |
drawableId notNil ifTrue:[
|
|
2451 |
device unmapWindow:drawableId
|
|
2452 |
].
|
|
2453 |
realized := false.
|
12
|
2454 |
shown := false
|
0
|
2455 |
]
|
20
|
2456 |
!
|
|
2457 |
|
|
2458 |
open
|
|
2459 |
"create and schedule a new windowgroup for me and open the view"
|
|
2460 |
|
|
2461 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
2462 |
windowGroup isNil ifTrue:[
|
|
2463 |
windowGroup := WindowGroup new.
|
|
2464 |
windowGroup addTopView:self.
|
|
2465 |
].
|
|
2466 |
windowGroup startup.
|
|
2467 |
].
|
|
2468 |
^ self realize
|
|
2469 |
!
|
|
2470 |
|
|
2471 |
openModal
|
|
2472 |
"create a new windowgroup, but start processing in the current process
|
|
2473 |
actually suspending event processing for the currently active group"
|
|
2474 |
|
|
2475 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
2476 |
windowGroup isNil ifTrue:[
|
|
2477 |
windowGroup := WindowGroup new.
|
|
2478 |
windowGroup addTopView:self.
|
|
2479 |
].
|
|
2480 |
self realize.
|
|
2481 |
self windowGroup eventLoop
|
|
2482 |
] ifFalse:[
|
|
2483 |
self realize
|
|
2484 |
]
|
0
|
2485 |
! !
|
|
2486 |
|
|
2487 |
!View methodsFor:'drawing'!
|
|
2488 |
|
|
2489 |
drawEdgesForX:x y:y width:w height:h level:l
|
|
2490 |
shadow:shadowColor light:lightColor
|
|
2491 |
halfShadow:halfShadowColor halfLight:halfLightColor
|
|
2492 |
"draw 3D edges into a rectangle"
|
|
2493 |
|
|
2494 |
|topLeftFg botRightFg topLeftHalfFg botRightHalfFg
|
|
2495 |
count "{ Class: SmallInteger }"
|
|
2496 |
r "{ Class: SmallInteger }"
|
|
2497 |
b "{ Class: SmallInteger }"
|
|
2498 |
xi "{ Class: SmallInteger }"
|
|
2499 |
yi "{ Class: SmallInteger }"
|
|
2500 |
run |
|
|
2501 |
|
|
2502 |
(l < 0) ifTrue:[
|
|
2503 |
topLeftFg := shadowColor.
|
|
2504 |
botRightFg := lightColor.
|
|
2505 |
topLeftHalfFg := halfShadowColor.
|
|
2506 |
botRightHalfFg := halfLightColor.
|
|
2507 |
count := l negated
|
|
2508 |
] ifFalse:[
|
|
2509 |
topLeftFg := lightColor.
|
|
2510 |
botRightFg := shadowColor.
|
|
2511 |
topLeftHalfFg := halfLightColor.
|
|
2512 |
botRightHalfFg := halfShadowColor.
|
|
2513 |
count := l
|
|
2514 |
].
|
|
2515 |
r := x + w - 1. "right"
|
|
2516 |
b := y + h - 1. "bottom"
|
|
2517 |
|
|
2518 |
super lineWidth:0.
|
|
2519 |
|
|
2520 |
"top and left edges"
|
|
2521 |
(softEdge and:[l > 0]) ifTrue:[
|
|
2522 |
super paint:topLeftHalfFg
|
|
2523 |
] ifFalse:[
|
|
2524 |
super paint:topLeftFg
|
|
2525 |
].
|
|
2526 |
0 to:(count - 1) do:[:i |
|
|
2527 |
run := y + i.
|
|
2528 |
super displayLineFromX:x y:run toX:r y:run. "top"
|
|
2529 |
run := x + i.
|
|
2530 |
super displayLineFromX:run y:y toX:run y:b "left"
|
|
2531 |
].
|
|
2532 |
softEdge ifTrue:[
|
|
2533 |
"
|
|
2534 |
super paint:topLeftFg.
|
|
2535 |
super displayLineFromX:x y:y toX:r y:y.
|
|
2536 |
super displayLineFromX:x y:y toX:x y:b
|
|
2537 |
"
|
|
2538 |
(l > 2) ifTrue:[
|
|
2539 |
super paint:Black.
|
|
2540 |
super displayLineFromX:x y:y toX:r y:y.
|
|
2541 |
super displayLineFromX:x y:y toX:x y:b.
|
|
2542 |
]
|
|
2543 |
].
|
|
2544 |
|
|
2545 |
xi := x + 1.
|
|
2546 |
yi := y + 1.
|
|
2547 |
|
|
2548 |
"bottom and right edges"
|
|
2549 |
(softEdge) ifTrue:[
|
|
2550 |
super paint:botRightHalfFg
|
|
2551 |
] ifFalse:[
|
|
2552 |
super paint:botRightFg
|
|
2553 |
].
|
|
2554 |
0 to:(count - 1) do:[:i |
|
|
2555 |
run := b - i.
|
|
2556 |
super displayLineFromX:xi-1 y:run toX:r y:run. "bottom"
|
|
2557 |
run := r - i.
|
|
2558 |
super displayLineFromX:run y:yi-1 toX:run y:b. "right"
|
|
2559 |
xi := xi + 1.
|
|
2560 |
yi := yi + 1
|
|
2561 |
].
|
|
2562 |
(softEdge and:[l > 1]) ifTrue:[
|
|
2563 |
super paint:shadowColor.
|
|
2564 |
super displayLineFromX:(x + 1-1) y:b toX:r y:b.
|
|
2565 |
super displayLineFromX:r y:(y + 1 - 1) toX:r y:b
|
|
2566 |
]
|
|
2567 |
!
|
|
2568 |
|
|
2569 |
drawEdgesForX:x y:y width:w height:h level:l
|
|
2570 |
"draw 3D edges into a rectangle"
|
|
2571 |
|
|
2572 |
self drawEdgesForX:x y:y width:w height:h level:l
|
|
2573 |
shadow:shadowColor light:lightColor
|
|
2574 |
halfShadow:halfShadowColor halfLight:halfLightColor
|
|
2575 |
!
|
|
2576 |
|
|
2577 |
drawLeftEdge
|
|
2578 |
"draw left 3D edge into window frame"
|
|
2579 |
|
|
2580 |
|leftFg leftHalfFg
|
|
2581 |
count "{ Class: SmallInteger }" |
|
|
2582 |
|
|
2583 |
(level < 0) ifTrue:[
|
|
2584 |
leftFg := shadowColor.
|
|
2585 |
leftHalfFg := halfShadowColor.
|
|
2586 |
count := level negated
|
|
2587 |
] ifFalse:[
|
|
2588 |
leftFg := lightColor.
|
|
2589 |
leftHalfFg := halfLightColor.
|
|
2590 |
count := level
|
|
2591 |
].
|
|
2592 |
|
|
2593 |
super lineWidth:0.
|
|
2594 |
(softEdge and:[level > 0]) ifTrue:[
|
|
2595 |
super paint:leftHalfFg
|
|
2596 |
] ifFalse:[
|
|
2597 |
super paint:leftFg
|
|
2598 |
].
|
|
2599 |
0 to:(count - 1) do:[:i |
|
|
2600 |
super displayLineFromX:i y:i toX:i y:(height - 1 - i)
|
|
2601 |
].
|
|
2602 |
(softEdge and:[level > 2]) ifTrue:[
|
|
2603 |
super paint:Black.
|
|
2604 |
super displayLineFromX:0 y:0 toX:0 y:height-1.
|
|
2605 |
]
|
|
2606 |
!
|
|
2607 |
|
|
2608 |
drawRightEdge
|
|
2609 |
"draw right 3D edge into window frame"
|
|
2610 |
|
|
2611 |
|rightFg
|
|
2612 |
count "{ Class: SmallInteger }"
|
|
2613 |
r|
|
|
2614 |
|
|
2615 |
(level < 0) ifTrue:[
|
|
2616 |
rightFg := lightColor.
|
|
2617 |
count := level negated
|
|
2618 |
] ifFalse:[
|
|
2619 |
(softEdge and:[level > 1]) ifTrue:[
|
|
2620 |
rightFg := halfShadowColor
|
|
2621 |
] ifFalse:[
|
|
2622 |
rightFg := shadowColor
|
|
2623 |
].
|
|
2624 |
count := level
|
|
2625 |
].
|
|
2626 |
|
|
2627 |
super lineWidth:0.
|
|
2628 |
super paint:rightFg.
|
|
2629 |
0 to:(count - 1) do:[:i |
|
|
2630 |
r := width - 1 - i.
|
|
2631 |
super displayLineFromX:r y:i toX:r y:(height - 1 - i)
|
|
2632 |
].
|
|
2633 |
(softEdge and:[level > 1]) ifTrue:[
|
|
2634 |
super paint:shadowColor.
|
|
2635 |
super displayLineFromX:width-1 y:1 toX:width-1 y:height-1.
|
|
2636 |
]
|
|
2637 |
!
|
|
2638 |
|
|
2639 |
drawTopEdge
|
|
2640 |
"draw top 3D edge into window frame"
|
|
2641 |
|
|
2642 |
|topFg topHalfFg
|
|
2643 |
count "{ Class: SmallInteger }" |
|
|
2644 |
|
|
2645 |
(level < 0) ifTrue:[
|
|
2646 |
topFg := shadowColor.
|
|
2647 |
topHalfFg := halfShadowColor.
|
|
2648 |
count := level negated
|
|
2649 |
] ifFalse:[
|
|
2650 |
topFg := lightColor.
|
|
2651 |
topHalfFg := halfLightColor.
|
|
2652 |
count := level
|
|
2653 |
].
|
|
2654 |
|
|
2655 |
super lineWidth:0.
|
|
2656 |
(softEdge and:[level > 0]) ifTrue:[
|
|
2657 |
super paint:topHalfFg
|
|
2658 |
] ifFalse:[
|
|
2659 |
super paint:topFg
|
|
2660 |
].
|
|
2661 |
0 to:(count - 1) do:[:i |
|
|
2662 |
super displayLineFromX:i y:i toX:(width - 1 - i) y:i
|
|
2663 |
].
|
|
2664 |
(softEdge and:[level > 2]) ifTrue:[
|
|
2665 |
super paint:Black.
|
|
2666 |
super displayLineFromX:0 y:0 toX:width-1 y:0.
|
|
2667 |
]
|
|
2668 |
!
|
|
2669 |
|
|
2670 |
drawBottomEdge
|
|
2671 |
"draw bottom 3D edge into window frame"
|
|
2672 |
|
|
2673 |
|botFg
|
|
2674 |
count "{ Class: SmallInteger }"
|
|
2675 |
b|
|
|
2676 |
|
|
2677 |
(level < 0) ifTrue:[
|
|
2678 |
botFg := lightColor.
|
|
2679 |
count := level negated
|
|
2680 |
] ifFalse:[
|
|
2681 |
(softEdge and:[level > 1]) ifTrue:[
|
|
2682 |
botFg := halfShadowColor
|
|
2683 |
] ifFalse:[
|
|
2684 |
botFg := shadowColor
|
|
2685 |
].
|
|
2686 |
count := level
|
|
2687 |
].
|
|
2688 |
|
|
2689 |
super lineWidth:0.
|
|
2690 |
super paint:botFg.
|
|
2691 |
0 to:(count - 1) do:[:i |
|
|
2692 |
b := height - 1 - i.
|
|
2693 |
super displayLineFromX:i y:b toX:(width "- 1" - i) y:b
|
|
2694 |
].
|
|
2695 |
(softEdge and:[level > 1]) ifTrue:[
|
|
2696 |
super paint:shadowColor.
|
|
2697 |
super displayLineFromX:1 y:height-1 toX:width-1 y:height-1.
|
|
2698 |
]
|
|
2699 |
!
|
|
2700 |
|
|
2701 |
redrawEdges
|
|
2702 |
"redraw my edges if 3D"
|
|
2703 |
|
|
2704 |
self is3D ifTrue:[
|
|
2705 |
(level ~~ 0) ifTrue:[
|
|
2706 |
self clipRect:nil.
|
|
2707 |
self drawEdgesForX:0 y:0
|
|
2708 |
width:width height:height
|
|
2709 |
level:level.
|
|
2710 |
self clipRect:innerClipRect
|
|
2711 |
]
|
|
2712 |
]
|
|
2713 |
!
|
|
2714 |
|
|
2715 |
redraw
|
|
2716 |
"redraw myself
|
|
2717 |
if there is a model, this one shall redraw itself,
|
|
2718 |
otherwise we cannot do much here - has to be redefined in subclasses"
|
|
2719 |
|
|
2720 |
model notNil ifTrue:[
|
|
2721 |
model update:self
|
|
2722 |
]
|
|
2723 |
!
|
|
2724 |
|
|
2725 |
redrawX:x y:y width:w height:h
|
|
2726 |
"have to redraw part -
|
|
2727 |
default is to redraw everything - subclasses should add intelligence"
|
|
2728 |
|
|
2729 |
|area|
|
|
2730 |
|
|
2731 |
area := Rectangle left:x top:y width:w height:h.
|
|
2732 |
self clippedTo:area do:[
|
|
2733 |
controller notNil ifTrue:[
|
|
2734 |
"ST-80 updating"
|
|
2735 |
self update:#rectangle with:area
|
|
2736 |
] ifFalse:[
|
|
2737 |
components notNil ifTrue:[
|
|
2738 |
components do:[:aComponent |
|
|
2739 |
(aComponent frame intersects:area) ifTrue:[
|
|
2740 |
aComponent drawIn:self offset:0@0
|
|
2741 |
]
|
|
2742 |
]
|
|
2743 |
] ifFalse:[
|
|
2744 |
self redraw
|
|
2745 |
]
|
|
2746 |
]
|
|
2747 |
]
|
|
2748 |
! !
|
|
2749 |
|
|
2750 |
!View methodsFor:'events'!
|
|
2751 |
|
12
|
2752 |
destroyed
|
|
2753 |
"view has been destroyed by someone else"
|
|
2754 |
|
|
2755 |
shown := false.
|
|
2756 |
super destroyed
|
|
2757 |
!
|
|
2758 |
|
0
|
2759 |
sizeChanged:how
|
|
2760 |
"tell subviews if I change size"
|
|
2761 |
|
|
2762 |
transformation := nil. "transformation becomes void"
|
|
2763 |
subViews notNil ifTrue:[
|
|
2764 |
(how == #smaller) ifTrue:[
|
|
2765 |
subViews do:[:view |
|
|
2766 |
view superViewChangedSize
|
|
2767 |
]
|
|
2768 |
] ifFalse:[
|
|
2769 |
"doing it reverse speeds up resizing - usually subviews
|
|
2770 |
are created from top-left to bottom-right; therefore
|
|
2771 |
bottom-right views will be moved/resized first, then top-left ones;
|
|
2772 |
this avoids multiple redraws of subviews"
|
|
2773 |
|
|
2774 |
subViews reverseDo:[:view |
|
|
2775 |
view superViewChangedSize
|
|
2776 |
]
|
|
2777 |
]
|
|
2778 |
]
|
|
2779 |
!
|
|
2780 |
|
|
2781 |
superViewChangedSize
|
|
2782 |
"my superView has changed size; if I have relative
|
|
2783 |
origin/extent or blocks to evaluate, do it now .."
|
|
2784 |
|
|
2785 |
|oldWidth oldHeight oldTop oldLeft newExt newOrg
|
|
2786 |
winSuper newWidth newHeight newLeft newTop newCorner
|
|
2787 |
superWidth superHeight superWinWidth superWinHeight|
|
|
2788 |
|
|
2789 |
oldWidth := width.
|
|
2790 |
oldHeight := height.
|
|
2791 |
oldTop := top.
|
|
2792 |
oldLeft := left.
|
|
2793 |
|
|
2794 |
viewport notNil ifTrue:[
|
|
2795 |
"if this view has a viewPort, resize a la st-80"
|
|
2796 |
superView isNil ifTrue:[^ self].
|
|
2797 |
winSuper := superView window.
|
|
2798 |
winSuper isNil ifTrue:[
|
|
2799 |
"take pixel size as window"
|
|
2800 |
winSuper := 0@0 extent:(superView width@superView height)
|
|
2801 |
].
|
|
2802 |
|
|
2803 |
|
|
2804 |
superWidth := superView width.
|
|
2805 |
superHeight := superView height.
|
|
2806 |
superWinWidth := winSuper width.
|
|
2807 |
superWinHeight := winSuper height.
|
|
2808 |
newLeft := (viewport left - winSuper left) * superWidth // superWinWidth.
|
|
2809 |
newTop := (viewport top - winSuper top) * superHeight // superWinHeight.
|
|
2810 |
newWidth := superWidth * viewport width // superWinWidth.
|
|
2811 |
newHeight := superHeight * viewport height // superWinHeight.
|
|
2812 |
self pixelOrigin:(newLeft @ newTop).
|
|
2813 |
self pixelExtent:(newWidth @ newHeight).
|
|
2814 |
^ self
|
|
2815 |
].
|
|
2816 |
|
|
2817 |
(originRule notNil) ifTrue:[
|
|
2818 |
newOrg := originRule value
|
|
2819 |
] ifFalse:[
|
|
2820 |
(relativeOrigin notNil) ifTrue:[
|
|
2821 |
"self originFromRelativeOrigin "
|
|
2822 |
newOrg := self originFromRelativeOrigin.
|
|
2823 |
"
|
|
2824 |
borderWidth ~~ 0 ifTrue:[
|
|
2825 |
newOrg := newOrg - (borderWidth @ borderWidth)
|
|
2826 |
]
|
|
2827 |
"
|
|
2828 |
]
|
|
2829 |
].
|
|
2830 |
|
|
2831 |
(cornerRule notNil) ifTrue:[
|
|
2832 |
newCorner := cornerRule value
|
|
2833 |
] ifFalse:[
|
|
2834 |
(relativeCorner notNil) ifTrue:[
|
|
2835 |
newCorner := self cornerFromRelativeCorner
|
|
2836 |
] ifFalse:[
|
|
2837 |
(extentRule notNil) ifTrue:[
|
|
2838 |
newExt := extentRule value
|
|
2839 |
] ifFalse:[
|
|
2840 |
(relativeExtent notNil) ifTrue:[
|
|
2841 |
newExt := self extentFromRelativeExtent
|
|
2842 |
]
|
|
2843 |
].
|
|
2844 |
]
|
|
2845 |
].
|
|
2846 |
|
|
2847 |
newOrg notNil ifTrue:[
|
|
2848 |
((newOrg x == oldLeft) and:[newOrg y == oldTop]) ifTrue:[
|
|
2849 |
newOrg := nil
|
|
2850 |
]
|
|
2851 |
].
|
|
2852 |
newCorner notNil ifTrue:[
|
|
2853 |
(newCorner = self corner) ifTrue:[
|
|
2854 |
newCorner := nil
|
|
2855 |
] ifFalse:[
|
|
2856 |
self corner isNil ifTrue:[
|
|
2857 |
newExt notNil ifTrue:[
|
|
2858 |
((newExt x == oldWidth) and:[newExt y == oldHeight]) ifTrue:[
|
|
2859 |
newExt := nil
|
|
2860 |
]
|
|
2861 |
].
|
|
2862 |
]
|
|
2863 |
]
|
|
2864 |
].
|
|
2865 |
|
|
2866 |
newCorner isNil ifTrue:[
|
|
2867 |
newExt isNil ifTrue:[
|
|
2868 |
newOrg notNil ifTrue:[
|
|
2869 |
self pixelOrigin:newOrg
|
|
2870 |
]
|
|
2871 |
] ifFalse:[
|
|
2872 |
newOrg isNil ifTrue:[
|
|
2873 |
self pixelExtent:newExt
|
|
2874 |
] ifFalse:[
|
|
2875 |
self pixelOrigin:newOrg extent:newExt
|
|
2876 |
]
|
|
2877 |
]
|
|
2878 |
] ifFalse:[
|
|
2879 |
newOrg isNil ifTrue:[
|
|
2880 |
self pixelCorner:newCorner
|
|
2881 |
] ifFalse:[
|
|
2882 |
self pixelOrigin:newOrg corner:newCorner
|
|
2883 |
]
|
|
2884 |
]
|
|
2885 |
!
|
|
2886 |
|
|
2887 |
configureX:x y:y width:newWidth height:newHeight
|
|
2888 |
"my size has changed by window manager action"
|
|
2889 |
|
|
2890 |
|how anyEdge mustRedrawBottomEdge mustRedrawRightEdge|
|
|
2891 |
|
|
2892 |
left := x.
|
|
2893 |
top := y.
|
|
2894 |
((width ~~ newWidth) or:[height ~~ newHeight]) ifTrue:[
|
|
2895 |
realized ifFalse:[
|
|
2896 |
width := newWidth.
|
|
2897 |
height := newHeight.
|
|
2898 |
extentChanged := true.
|
|
2899 |
^ self
|
|
2900 |
].
|
|
2901 |
|
|
2902 |
((newWidth <= width) and:[newHeight <= height]) ifTrue:[
|
|
2903 |
how := #smaller
|
|
2904 |
].
|
|
2905 |
|
|
2906 |
self is3D ifTrue:[
|
|
2907 |
mustRedrawBottomEdge := newHeight < height.
|
|
2908 |
mustRedrawRightEdge := newWidth < width.
|
|
2909 |
anyEdge := mustRedrawBottomEdge or:[mustRedrawRightEdge]
|
|
2910 |
] ifFalse:[
|
|
2911 |
anyEdge := false
|
|
2912 |
].
|
|
2913 |
|
|
2914 |
width := newWidth.
|
|
2915 |
height := newHeight.
|
|
2916 |
|
|
2917 |
"recompute inner-clip if needed"
|
|
2918 |
self setInnerClip.
|
|
2919 |
|
12
|
2920 |
self sizeChanged:how.
|
0
|
2921 |
|
|
2922 |
anyEdge ifTrue:[
|
|
2923 |
self clipRect:nil.
|
|
2924 |
mustRedrawBottomEdge ifTrue:[
|
|
2925 |
self drawBottomEdge
|
|
2926 |
].
|
|
2927 |
mustRedrawRightEdge ifTrue:[
|
|
2928 |
self drawRightEdge
|
|
2929 |
].
|
|
2930 |
self clipRect:innerClipRect
|
|
2931 |
]
|
|
2932 |
]
|
|
2933 |
!
|
|
2934 |
|
|
2935 |
mapped
|
|
2936 |
"the view has been mapped (by some outside
|
|
2937 |
action - i.e. window manager de-iconified me)"
|
|
2938 |
|
|
2939 |
realized := true.
|
|
2940 |
shown := true
|
|
2941 |
!
|
|
2942 |
|
|
2943 |
unmapped
|
|
2944 |
"the view has been unmapped (by some outside
|
|
2945 |
action - i.e. window manager iconified me)"
|
|
2946 |
|
|
2947 |
shown := false
|
|
2948 |
!
|
|
2949 |
|
12
|
2950 |
reparented
|
|
2951 |
"the view has changed its parent by some outside
|
|
2952 |
action - i.e. window manager has added a frame.
|
|
2953 |
nothing done here"
|
|
2954 |
|
|
2955 |
^ self
|
|
2956 |
!
|
|
2957 |
|
0
|
2958 |
exposeX:x y:y width:w height:h
|
|
2959 |
"a low level redraw event from device
|
|
2960 |
- let subclass handle the redraw and take care of edges here"
|
|
2961 |
|
|
2962 |
|leftEdge topEdge rightEdge botEdge anyEdge nx ny nw nh|
|
|
2963 |
|
|
2964 |
nw := w.
|
|
2965 |
nh := h.
|
|
2966 |
nx := x.
|
|
2967 |
ny := y.
|
|
2968 |
|
|
2969 |
anyEdge := false.
|
|
2970 |
|
|
2971 |
"check if there is a need to draw an edge"
|
|
2972 |
|
|
2973 |
(margin ~~ 0) ifTrue:[
|
|
2974 |
leftEdge := false.
|
|
2975 |
topEdge := false.
|
|
2976 |
rightEdge := false.
|
|
2977 |
botEdge := false.
|
|
2978 |
(x < margin) ifTrue:[
|
|
2979 |
nx := margin.
|
|
2980 |
nw := nw - (nx - x).
|
|
2981 |
leftEdge := true.
|
|
2982 |
anyEdge := true
|
|
2983 |
].
|
|
2984 |
((x + w - 1) >= (width - margin)) ifTrue:[
|
|
2985 |
nw := (width - margin - nx).
|
|
2986 |
rightEdge := true.
|
|
2987 |
anyEdge := true
|
|
2988 |
].
|
|
2989 |
(y < margin) ifTrue:[
|
|
2990 |
ny := margin.
|
|
2991 |
nh := nh - (ny - y).
|
|
2992 |
topEdge := true.
|
|
2993 |
anyEdge := true
|
|
2994 |
].
|
|
2995 |
((y + h - 1) >= (height - margin)) ifTrue:[
|
|
2996 |
nh := (height - margin - ny).
|
|
2997 |
botEdge := true.
|
|
2998 |
anyEdge := true
|
|
2999 |
]
|
|
3000 |
].
|
|
3001 |
|
|
3002 |
"redraw inside area"
|
|
3003 |
|
|
3004 |
self redrawX:nx y:ny width:nw height:nh.
|
|
3005 |
|
|
3006 |
"redraw edge(s)"
|
|
3007 |
|
|
3008 |
anyEdge ifTrue:[
|
|
3009 |
self clipRect:nil.
|
|
3010 |
(topEdge and:[leftEdge and:[botEdge and:[rightEdge]]]) ifTrue:[
|
|
3011 |
self drawEdgesForX:0 y:0
|
|
3012 |
width:width height:height
|
|
3013 |
level:level
|
|
3014 |
] ifFalse:[
|
|
3015 |
topEdge ifTrue:[
|
|
3016 |
self drawTopEdge
|
|
3017 |
].
|
|
3018 |
leftEdge ifTrue:[
|
|
3019 |
self drawLeftEdge
|
|
3020 |
].
|
|
3021 |
botEdge ifTrue:[
|
|
3022 |
self drawBottomEdge
|
|
3023 |
].
|
|
3024 |
rightEdge ifTrue:[
|
|
3025 |
self drawRightEdge
|
|
3026 |
]
|
|
3027 |
].
|
|
3028 |
self clipRect:innerClipRect
|
|
3029 |
]
|
|
3030 |
!
|
|
3031 |
|
|
3032 |
keyPress:key x:x y:y
|
|
3033 |
"a key has been pressed.
|
|
3034 |
if there is a keyboardHandler, pass input to him"
|
|
3035 |
|
|
3036 |
"allow forwarding events to the keyboardhandler"
|
|
3037 |
keyboardHandler notNil ifTrue:[
|
|
3038 |
keyboardHandler keyPress:key x:x y:y
|
|
3039 |
] ifFalse:[
|
|
3040 |
super keyPress:key x:x y:y
|
|
3041 |
]
|
|
3042 |
!
|
|
3043 |
|
|
3044 |
buttonPress:button x:x y:y
|
|
3045 |
"button was pressed - if its middle button and there is a menu, show it."
|
|
3046 |
|
|
3047 |
|menu menuSelector|
|
|
3048 |
|
|
3049 |
(button == 2) ifTrue:[
|
|
3050 |
"try ST-80 style menus first"
|
|
3051 |
model notNil ifTrue:[
|
|
3052 |
menuSymbol notNil ifTrue:[
|
|
3053 |
menu := model perform:menuSymbol.
|
|
3054 |
menu notNil ifTrue:[
|
|
3055 |
menuSelector := menu startUp.
|
|
3056 |
menuSelector ~~ 0 ifTrue:[
|
|
3057 |
model perform:menuSelector
|
|
3058 |
]
|
|
3059 |
].
|
|
3060 |
^ self
|
|
3061 |
]
|
|
3062 |
]
|
|
3063 |
].
|
|
3064 |
super buttonPress:button x:x y:y
|
|
3065 |
!
|
|
3066 |
|
12
|
3067 |
XXXwaitForExpose
|
0
|
3068 |
"after a scroll, we have to wait for expose/noexpose"
|
|
3069 |
|
|
3070 |
device dispatchExposeEventsFor:drawableId
|
|
3071 |
!
|
|
3072 |
|
|
3073 |
terminate
|
|
3074 |
"window manager wants me to go away"
|
|
3075 |
|
|
3076 |
^ self destroy
|
|
3077 |
!
|
|
3078 |
|
|
3079 |
saveAndTerminate
|
|
3080 |
"window manager wants me to save and go away"
|
|
3081 |
|
|
3082 |
^ self destroy
|
|
3083 |
! !
|