0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
72
|
3 |
All Rights Reserved
|
0
|
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 |
DeviceDrawable subclass:#PseudoView
|
|
14 |
instanceVariableNames:'viewBackground
|
72
|
15 |
cursor eventMask
|
|
16 |
middleButtonMenu
|
|
17 |
keyCommands
|
|
18 |
gotExpose exposePending
|
|
19 |
backed saveUnder delegate'
|
0
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'Views-Basic'
|
|
23 |
!
|
|
24 |
|
|
25 |
PseudoView comment:'
|
6
|
26 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
72
|
27 |
All Rights Reserved
|
54
|
28 |
|
110
|
29 |
$Header: /cvs/stx/stx/libview/Attic/PseudoV.st,v 1.27 1995-02-28 21:50:26 claus Exp $
|
0
|
30 |
'!
|
|
31 |
|
40
|
32 |
!PseudoView class methodsFor:'documentation'!
|
|
33 |
|
46
|
34 |
copyright
|
|
35 |
"
|
|
36 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
72
|
37 |
All Rights Reserved
|
46
|
38 |
|
|
39 |
This software is furnished under a license and may be used
|
|
40 |
only in accordance with the terms of that license and with the
|
|
41 |
inclusion of the above copyright notice. This software may not
|
|
42 |
be provided or otherwise made available to, or used by, any
|
|
43 |
other person. No title to or ownership of the software is
|
|
44 |
hereby transferred.
|
|
45 |
"
|
|
46 |
!
|
|
47 |
|
|
48 |
version
|
|
49 |
"
|
110
|
50 |
$Header: /cvs/stx/stx/libview/Attic/PseudoV.st,v 1.27 1995-02-28 21:50:26 claus Exp $
|
46
|
51 |
"
|
|
52 |
!
|
|
53 |
|
40
|
54 |
documentation
|
|
55 |
"
|
59
|
56 |
this abstract class describes stuff common to any Window on a display
|
|
57 |
device. i.e. RootWindow, TopWindows, PopUps and Subwindows.
|
|
58 |
That is, they have a viewBackground, cursor etc. and especially events.
|
|
59 |
A special feature is the delegate field, which allows key- and button
|
|
60 |
events to be stolen from a view.
|
|
61 |
If the delegate is non-nil, these events will be sent to it instead.
|
|
62 |
So you can change a views behavior even if it was not initially designed
|
|
63 |
for it. Also, controller functionality could be simulated using delegates.
|
|
64 |
|
|
65 |
instance variables:
|
|
66 |
|
72
|
67 |
viewBackground <Color|Form|Image> the views background
|
59
|
68 |
|
72
|
69 |
cursor <Cursor> the cursor
|
59
|
70 |
|
72
|
71 |
eventMask mask specifying the enabled
|
59
|
72 |
events.
|
|
73 |
|
72
|
74 |
middleButtonMenu a popup menu for the middle
|
59
|
75 |
button.
|
|
76 |
|
72
|
77 |
keyCommands not yet supported
|
59
|
78 |
|
72
|
79 |
gotExpose for exposure handling after
|
|
80 |
exposePending after a scroll
|
59
|
81 |
|
72
|
82 |
backed true if backing store for that
|
59
|
83 |
view is enabled
|
|
84 |
|
72
|
85 |
saveUnder true if saveunder store for
|
59
|
86 |
that view is enabled
|
|
87 |
|
72
|
88 |
delegate for event delegation
|
40
|
89 |
"
|
|
90 |
! !
|
|
91 |
|
0
|
92 |
!PseudoView methodsFor:'initialize / release'!
|
|
93 |
|
|
94 |
initialize
|
|
95 |
"initialize defaults"
|
|
96 |
|
|
97 |
super initialize.
|
109
|
98 |
|
|
99 |
eventMask := Display defaultEventMask.
|
0
|
100 |
viewBackground := background.
|
|
101 |
backed := false.
|
|
102 |
saveUnder := false.
|
|
103 |
exposePending := false.
|
|
104 |
self initCursor
|
|
105 |
!
|
|
106 |
|
12
|
107 |
initStyle
|
|
108 |
"nothing done here"
|
|
109 |
|
|
110 |
^ self
|
|
111 |
!
|
|
112 |
|
0
|
113 |
initCursor
|
12
|
114 |
"default cursor for all views"
|
|
115 |
|
0
|
116 |
cursor := Cursor arrow
|
|
117 |
!
|
|
118 |
|
12
|
119 |
reinitStyle
|
|
120 |
"nothing done here"
|
|
121 |
|
|
122 |
^ self
|
|
123 |
!
|
|
124 |
|
0
|
125 |
recreate
|
|
126 |
"recreate (i.e. tell X about me) after a snapin"
|
|
127 |
|
40
|
128 |
viewBackground isColor ifTrue:[
|
72
|
129 |
viewBackground := viewBackground on:device
|
0
|
130 |
].
|
46
|
131 |
super recreate.
|
0
|
132 |
cursor := cursor on:device.
|
|
133 |
exposePending := false
|
|
134 |
!
|
|
135 |
|
|
136 |
destroy
|
|
137 |
"view is about to be destroyed -
|
|
138 |
first destroy menu if there is one and also destroy the GC.
|
|
139 |
then the view is physically destroyed."
|
|
140 |
|
|
141 |
middleButtonMenu notNil ifTrue:[
|
72
|
142 |
middleButtonMenu destroy.
|
|
143 |
middleButtonMenu := nil
|
0
|
144 |
].
|
|
145 |
keyCommands := nil.
|
|
146 |
gcId notNil ifTrue:[
|
72
|
147 |
device destroyGC:gcId.
|
|
148 |
gcId := nil
|
0
|
149 |
].
|
|
150 |
drawableId notNil ifTrue:[
|
72
|
151 |
device destroyView:self withId:drawableId.
|
|
152 |
drawableId := nil
|
0
|
153 |
]
|
|
154 |
!
|
|
155 |
|
|
156 |
destroyed
|
|
157 |
"view has been destroyed by someone else"
|
|
158 |
|
12
|
159 |
drawableId notNil ifTrue:[
|
72
|
160 |
device removeKnownView:self.
|
|
161 |
drawableId := nil.
|
|
162 |
realized := false.
|
12
|
163 |
].
|
0
|
164 |
self destroy
|
|
165 |
!
|
|
166 |
|
|
167 |
reAdjustGeometry
|
|
168 |
"sent late during snapin processing, nothing done here"
|
|
169 |
|
|
170 |
^ self
|
|
171 |
! !
|
|
172 |
|
|
173 |
!PseudoView methodsFor:'accessing'!
|
|
174 |
|
|
175 |
viewOrigin
|
|
176 |
"0@0 here, since by default we cannot be scrolled"
|
|
177 |
|
|
178 |
^ 0 @ 0
|
|
179 |
!
|
|
180 |
|
|
181 |
viewGravity
|
|
182 |
"return the views gravity"
|
|
183 |
|
|
184 |
^ #NorthWest
|
|
185 |
!
|
|
186 |
|
|
187 |
depth
|
40
|
188 |
"return the depth in pixels of the view.
|
|
189 |
Notice, that this is currently the devices depth,
|
|
190 |
but support for mixed depth views is being prepared.
|
|
191 |
(especially useful on SGI, with 24bit view)"
|
0
|
192 |
|
|
193 |
^ device depth
|
|
194 |
!
|
|
195 |
|
|
196 |
viewBackground
|
|
197 |
"return the viewBackground"
|
|
198 |
|
|
199 |
^ viewBackground
|
|
200 |
!
|
|
201 |
|
|
202 |
viewBackground:something
|
89
|
203 |
"set the viewBackground to something, a color, image or form.
|
|
204 |
The viewBackground is the color or pattern with which exposed
|
|
205 |
regions are filled - do not confuse this with the drawing background
|
|
206 |
color, which is used with opaque drawing."
|
40
|
207 |
|
|
208 |
viewBackground ~~ something ifTrue:[
|
72
|
209 |
viewBackground := something.
|
|
210 |
drawableId notNil ifTrue:[
|
|
211 |
self setViewBackground
|
|
212 |
]
|
40
|
213 |
]
|
|
214 |
!
|
|
215 |
|
|
216 |
setViewBackground
|
|
217 |
"install the viewBackground for the receiver on the device"
|
0
|
218 |
|
|
219 |
|id devBgPixmap bgPixmap w h colors|
|
|
220 |
|
|
221 |
drawableId notNil ifTrue:[
|
72
|
222 |
viewBackground isColor ifTrue:[
|
|
223 |
viewBackground := viewBackground on:device.
|
|
224 |
id := viewBackground colorId.
|
|
225 |
"
|
|
226 |
a real color (i.e. one supported by the device) ?
|
|
227 |
"
|
|
228 |
id notNil ifTrue:[
|
|
229 |
device setWindowBackground:id in:drawableId.
|
|
230 |
^ self
|
|
231 |
].
|
|
232 |
"
|
|
233 |
no, a dithered one - must have a dither-pattern
|
|
234 |
(which is ready for the device, since viewBackground
|
|
235 |
is already assigned to the device)
|
|
236 |
"
|
|
237 |
bgPixmap := viewBackground ditherForm.
|
|
238 |
] ifFalse:[
|
|
239 |
"
|
|
240 |
assume, it can convert itself to a form
|
|
241 |
"
|
|
242 |
bgPixmap := viewBackground asFormOn:device
|
|
243 |
].
|
0
|
244 |
|
72
|
245 |
"
|
|
246 |
must now have:
|
|
247 |
a dithered color or bitmap or pixmap
|
|
248 |
"
|
|
249 |
bgPixmap isNil ifTrue:[
|
|
250 |
'background not convertable - ignored' errorPrintNewline.
|
|
251 |
^ self
|
|
252 |
].
|
40
|
253 |
|
72
|
254 |
w := bgPixmap width.
|
|
255 |
h := bgPixmap height.
|
40
|
256 |
|
72
|
257 |
(bgPixmap depth ~~ device depth) ifTrue:[
|
|
258 |
(bgPixmap depth ~~ 1) ifTrue:[
|
|
259 |
self error:'bad dither depth'.
|
|
260 |
^ self
|
|
261 |
].
|
|
262 |
"
|
|
263 |
convert it into a deep form
|
|
264 |
"
|
|
265 |
colors := bgPixmap colorMap.
|
|
266 |
devBgPixmap := Form width:w height:h depth:(device depth) on:device.
|
|
267 |
devBgPixmap paint:(colors at:1).
|
|
268 |
devBgPixmap fillRectangleX:0 y:0 width:w height:h.
|
|
269 |
devBgPixmap foreground:(colors at:2) background:(colors at:1).
|
|
270 |
devBgPixmap copyPlaneFrom:bgPixmap x:0 y:0 toX:0 y:0 width:w height:h.
|
|
271 |
bgPixmap := devBgPixmap.
|
|
272 |
] ifFalse:[
|
|
273 |
(bgPixmap depth == 1) ifTrue:[
|
|
274 |
"
|
|
275 |
although depth matches,
|
|
276 |
values in the dither are to be interpreted via the ditherForms
|
|
277 |
colormap, which is not always the same as blackpixel/whitepixel ...
|
|
278 |
"
|
|
279 |
(bgPixmap colorMap at:1) colorId == device whitepixel ifTrue:[
|
|
280 |
(bgPixmap colorMap at:2) colorId == device blackpixel ifTrue:[
|
|
281 |
"
|
|
282 |
ok, can use it
|
|
283 |
"
|
|
284 |
device setWindowBackgroundPixmap:(bgPixmap id) in:drawableId.
|
|
285 |
^ self
|
|
286 |
]
|
|
287 |
].
|
40
|
288 |
|
72
|
289 |
"
|
|
290 |
no, must invert it
|
|
291 |
"
|
|
292 |
devBgPixmap := Form width:w height:h depth:(device depth) on:device.
|
|
293 |
devBgPixmap paint:(bgPixmap colorMap at:2) on:(bgPixmap colorMap at:1).
|
|
294 |
devBgPixmap copyPlaneFrom:bgPixmap x:0 y:0 toX:0 y:0 width:w height:h.
|
|
295 |
bgPixmap := devBgPixmap.
|
|
296 |
]
|
|
297 |
].
|
|
298 |
device setWindowBackgroundPixmap:(bgPixmap id) in:drawableId.
|
0
|
299 |
]
|
|
300 |
!
|
|
301 |
|
|
302 |
insideColor:aColor
|
|
303 |
"set the views background color - ST-80 compatibility"
|
|
304 |
|
|
305 |
self viewBackground:aColor.
|
|
306 |
self background:aColor
|
40
|
307 |
! !
|
|
308 |
|
|
309 |
!PseudoView methodsFor:'accessing-cursor'!
|
0
|
310 |
|
|
311 |
cursor
|
|
312 |
"return the views cursor"
|
|
313 |
|
|
314 |
^ cursor
|
|
315 |
!
|
|
316 |
|
|
317 |
cursor:aCursor
|
|
318 |
"set the views cursor"
|
|
319 |
|
2
|
320 |
|id|
|
|
321 |
|
0
|
322 |
aCursor notNil ifTrue:[
|
72
|
323 |
(aCursor ~~ cursor) ifTrue:[
|
|
324 |
cursor := aCursor.
|
|
325 |
drawableId notNil ifTrue:[
|
|
326 |
cursor := cursor on:device.
|
|
327 |
id := cursor id.
|
|
328 |
id isNil ifTrue:[
|
|
329 |
'nil cursorId shape=' errorPrint. cursor shape errorPrintNewline.
|
|
330 |
^ self
|
|
331 |
].
|
|
332 |
device setCursor:id in:drawableId.
|
|
333 |
realized ifTrue:[
|
|
334 |
"flush, to make cursor immediately visible"
|
|
335 |
device synchronizeOutput
|
|
336 |
]
|
|
337 |
]
|
|
338 |
]
|
0
|
339 |
]
|
|
340 |
!
|
|
341 |
|
|
342 |
withCursor:aCursor do:aBlock
|
|
343 |
"evaluate aBlock showing aCursor until ready; then restore old cursor"
|
|
344 |
|
|
345 |
|savedCursor|
|
|
346 |
|
|
347 |
savedCursor := cursor.
|
|
348 |
self cursor:aCursor.
|
72
|
349 |
aBlock valueNowOrOnUnwindDo:[self cursor:savedCursor]
|
40
|
350 |
! !
|
|
351 |
|
|
352 |
!PseudoView methodsFor:'accessing-hierarchy'!
|
0
|
353 |
|
|
354 |
superView
|
|
355 |
"return the superView - nil here"
|
|
356 |
|
|
357 |
^ nil
|
|
358 |
!
|
|
359 |
|
|
360 |
topView
|
|
361 |
"return the topView - that the one with no superview"
|
|
362 |
|
|
363 |
^ self
|
|
364 |
!
|
|
365 |
|
12
|
366 |
delegate
|
|
367 |
"return the delegate - thats the one getting keyboard and button events"
|
0
|
368 |
|
12
|
369 |
^ delegate
|
|
370 |
!
|
|
371 |
|
|
372 |
delegate:someOne
|
|
373 |
"set the delegate"
|
|
374 |
|
|
375 |
delegate := someOne
|
40
|
376 |
! !
|
|
377 |
|
|
378 |
!PseudoView methodsFor:'accessing-names'!
|
0
|
379 |
|
|
380 |
label
|
40
|
381 |
"return the views label - this is nil here.
|
|
382 |
Only standardSystemViews support labels and icons."
|
0
|
383 |
|
|
384 |
^ nil
|
|
385 |
!
|
|
386 |
|
|
387 |
label:aLabel
|
40
|
388 |
"set the views label - ignored here.
|
|
389 |
Only standardSystemViews support labels and icons."
|
0
|
390 |
|
|
391 |
^ self
|
|
392 |
!
|
|
393 |
|
24
|
394 |
iconLabel
|
40
|
395 |
"return the views icon label - this is nil here.
|
|
396 |
Only standardSystemViews support labels and icons."
|
24
|
397 |
|
|
398 |
^ nil
|
|
399 |
!
|
|
400 |
|
|
401 |
iconLabel:aLabel
|
40
|
402 |
"set the views icon label - ignored here.
|
|
403 |
Only standardSystemViews support labels and icons."
|
0
|
404 |
|
|
405 |
^ self
|
|
406 |
!
|
|
407 |
|
|
408 |
iconView
|
40
|
409 |
"return the views iconView - this is nil here.
|
|
410 |
Only standardSystemViews support labels and icons."
|
0
|
411 |
|
|
412 |
^ nil
|
|
413 |
!
|
|
414 |
|
24
|
415 |
iconView:aView
|
40
|
416 |
"set the views icon view - ignored here.
|
|
417 |
Only standardSystemViews support labels and icons."
|
24
|
418 |
|
|
419 |
^ self
|
|
420 |
!
|
|
421 |
|
0
|
422 |
icon
|
40
|
423 |
"return the views icon - this is nil here.
|
|
424 |
Only standardSystemViews support labels and icons."
|
0
|
425 |
|
|
426 |
^ nil
|
|
427 |
!
|
|
428 |
|
24
|
429 |
icon:aBitmap
|
40
|
430 |
"set the views icon - ignored here.
|
|
431 |
Only standardSystemViews support labels and icons."
|
|
432 |
|
|
433 |
^ self
|
|
434 |
! !
|
|
435 |
|
|
436 |
!PseudoView methodsFor:'queries-contents'!
|
|
437 |
|
|
438 |
heightOfContents
|
|
439 |
"return the height of the contents in pixels.
|
|
440 |
Since we dont know here, just return the views size.
|
|
441 |
This will make your scrollbars show 100%-visible.
|
|
442 |
Must be redefined in subviews to make scrollbars really work."
|
|
443 |
|
|
444 |
^ self height
|
|
445 |
!
|
|
446 |
|
|
447 |
widthOfContents
|
|
448 |
"return the width of the contents in pixels.
|
|
449 |
Since we dont know here, just return the views size.
|
|
450 |
This will make your scrollbars show 100%-visible.
|
|
451 |
Must be redefined in subviews to make scrollbars really work."
|
|
452 |
|
|
453 |
^ self width
|
|
454 |
!
|
|
455 |
|
|
456 |
yOriginOfContents
|
|
457 |
"return the y-origin of the contents in pixels.
|
|
458 |
Since we dont know here, just return 0 for top.
|
|
459 |
Must be redefined in subviews to make scrollbars really work."
|
|
460 |
|
|
461 |
^ 0
|
|
462 |
!
|
|
463 |
|
|
464 |
xOriginOfContents
|
|
465 |
"return the x-origin of the contents in pixels.
|
|
466 |
Since we dont know here, just return 0 for left.
|
|
467 |
Must be redefined in subviews to make scrollbars really work."
|
|
468 |
|
|
469 |
^ 0
|
|
470 |
! !
|
|
471 |
|
|
472 |
!PseudoView methodsFor:'accessing-limits'!
|
|
473 |
|
|
474 |
minExtent:extent
|
|
475 |
"set the views minimum extent - ignored here.
|
|
476 |
Only standardSystemViews support this."
|
24
|
477 |
|
|
478 |
^ self
|
|
479 |
!
|
|
480 |
|
40
|
481 |
minExtent
|
|
482 |
"return the views minimum extent - this is nil here.
|
|
483 |
Only standardSystemViews support this."
|
|
484 |
|
|
485 |
^ nil
|
|
486 |
!
|
|
487 |
|
|
488 |
maxExtent:extent
|
|
489 |
"set the views maximum extent - ignored here.
|
|
490 |
Only standardSystemViews support this."
|
|
491 |
|
|
492 |
^ self
|
|
493 |
!
|
|
494 |
|
|
495 |
maxExtent
|
|
496 |
"return the views maximum extent - this is nil here.
|
|
497 |
Only standardSystemViews support this."
|
|
498 |
|
|
499 |
^ nil
|
|
500 |
! !
|
|
501 |
|
|
502 |
!PseudoView methodsFor:'accessing-misc'!
|
|
503 |
|
12
|
504 |
realized
|
|
505 |
"return true, if the receiver is realized"
|
|
506 |
|
|
507 |
^ realized
|
|
508 |
!
|
|
509 |
|
0
|
510 |
inputOnly
|
40
|
511 |
"return true, if the receiver is an input only view - that is:
|
|
512 |
the view will realize as a transparent view, into which you cannot
|
|
513 |
draw, but get events as usual. Thich can be used to catch events away from
|
|
514 |
others, which where never meant to work in such a setup.
|
|
515 |
(for example, if you want to manipulate views in some DrawTool-like manner).
|
|
516 |
This uses a special X feature, which might not be supported in the near future
|
|
517 |
or on other plattforms."
|
12
|
518 |
|
0
|
519 |
^ false
|
|
520 |
!
|
|
521 |
|
89
|
522 |
getKeyboardFocus
|
|
523 |
"tell the Display to assign keyboard focus to the receiver"
|
|
524 |
|
|
525 |
device setInputFocusTo:drawableId.
|
|
526 |
!
|
|
527 |
|
0
|
528 |
eventMask
|
|
529 |
"return a (numeric) mask of allowed events -
|
40
|
530 |
this is X-specific and will be removed / replaced by symbolic values)"
|
0
|
531 |
|
|
532 |
^ eventMask
|
|
533 |
!
|
|
534 |
|
|
535 |
eventMask:aMask
|
|
536 |
"set a (numeric) mask of allowed events -
|
40
|
537 |
this is X-specific and will be removed / replaced by symbolic values)"
|
0
|
538 |
|
|
539 |
eventMask := aMask
|
|
540 |
!
|
|
541 |
|
|
542 |
clipByChildren
|
|
543 |
"drawing shall be done into my view only (default)"
|
|
544 |
|
|
545 |
gcId isNil ifTrue:[
|
72
|
546 |
self initGC
|
0
|
547 |
].
|
|
548 |
device setClipByChildren:true in:gcId
|
|
549 |
!
|
|
550 |
|
|
551 |
noClipByChildren
|
|
552 |
"drawing shall also be done into subviews"
|
|
553 |
|
|
554 |
gcId isNil ifTrue:[
|
72
|
555 |
self initGC
|
0
|
556 |
].
|
|
557 |
device setClipByChildren:false in:gcId
|
|
558 |
!
|
|
559 |
|
|
560 |
saveUnder:aBoolean
|
|
561 |
"turn on/off saveUnder (saving pixels under myself)
|
|
562 |
- used for temporary views (i.e. PopUps and ModalBoxes)"
|
|
563 |
|
|
564 |
saveUnder := aBoolean.
|
|
565 |
drawableId notNil ifTrue:[
|
72
|
566 |
device setSaveUnder:aBoolean in:drawableId
|
0
|
567 |
]
|
|
568 |
!
|
|
569 |
|
|
570 |
backingStore:how
|
|
571 |
"turn on/off backingStore (saving my pixels)
|
2
|
572 |
how may true/false, but also #always, #whenMapped or #never."
|
0
|
573 |
|
2
|
574 |
how ~~ backed ifTrue:[
|
72
|
575 |
backed := how.
|
|
576 |
drawableId notNil ifTrue:[
|
|
577 |
device setBackingStore:how in:drawableId
|
|
578 |
]
|
0
|
579 |
]
|
24
|
580 |
!
|
|
581 |
|
|
582 |
preferedVisual
|
|
583 |
"return a non nil id, if a specific visual is wanted in this view.
|
|
584 |
Return nil if we do not care (i.e. the displays default is wanted).
|
|
585 |
This is experimental and may change/vanish - do not use it."
|
|
586 |
|
|
587 |
^ nil
|
|
588 |
!
|
|
589 |
|
|
590 |
preferedDepth
|
|
591 |
"return a non nil integer, if a specific depth is wanted in this view.
|
|
592 |
Return nil if we do not care (i.e. the displays default is wanted).
|
|
593 |
This is experimental and may change/vanish - do not use it."
|
|
594 |
|
|
595 |
^ nil
|
0
|
596 |
! !
|
|
597 |
|
|
598 |
!PseudoView methodsFor:'drawing'!
|
|
599 |
|
12
|
600 |
redraw
|
|
601 |
"nothing done here"
|
|
602 |
|
|
603 |
^ self
|
|
604 |
!
|
|
605 |
|
81
|
606 |
clearDeviceRectangleX:x y:y width:w height:h
|
0
|
607 |
"clear a rectangular area to viewBackground -
|
|
608 |
redefined since DisplayMedium fills with background
|
72
|
609 |
- not viewBackground as we want here."
|
|
610 |
|
|
611 |
|oldPaint|
|
|
612 |
|
|
613 |
oldPaint := paint.
|
|
614 |
self paint:viewBackground.
|
0
|
615 |
|
40
|
616 |
viewBackground isColor ifFalse:[
|
89
|
617 |
gcId notNil ifTrue:[
|
|
618 |
device setMaskOriginX:self viewOrigin x rounded negated
|
|
619 |
y:self viewOrigin y rounded negated
|
|
620 |
in:gcId
|
|
621 |
].
|
0
|
622 |
].
|
72
|
623 |
"
|
|
624 |
fill in device coordinates - not logical coordinates
|
|
625 |
"
|
|
626 |
self fillDeviceRectangleX:x y:y width:w height:h "with:viewBackground".
|
|
627 |
self paint:oldPaint
|
81
|
628 |
!
|
|
629 |
|
|
630 |
clearRectangleX:x y:y width:w height:h
|
|
631 |
"clear a rectangular area to viewBackground -
|
|
632 |
redefined since DisplayMedium fills with background
|
|
633 |
- not viewBackground as we want here."
|
|
634 |
|
|
635 |
|oldPaint|
|
|
636 |
|
|
637 |
oldPaint := paint.
|
|
638 |
self paint:viewBackground.
|
|
639 |
|
|
640 |
viewBackground isColor ifFalse:[
|
89
|
641 |
gcId notNil ifTrue:[
|
|
642 |
device setMaskOriginX:self viewOrigin x rounded negated
|
|
643 |
y:self viewOrigin y rounded negated
|
|
644 |
in:gcId
|
|
645 |
].
|
81
|
646 |
].
|
|
647 |
self fillRectangleX:x y:y width:w height:h.
|
|
648 |
self paint:oldPaint
|
0
|
649 |
! !
|
|
650 |
|
|
651 |
!PseudoView methodsFor:'keyboard commands'!
|
|
652 |
|
2
|
653 |
addActionForKey:aKey action:aBlock
|
|
654 |
"define a keyboard command function"
|
|
655 |
|
0
|
656 |
keyCommands isNil ifTrue:[
|
72
|
657 |
keyCommands := IdentityDictionary new
|
0
|
658 |
].
|
|
659 |
keyCommands at:aKey put:aBlock
|
|
660 |
!
|
|
661 |
|
2
|
662 |
removeActionForKey:aKey
|
|
663 |
keyCommands notNil ifTrue:[
|
72
|
664 |
keyCommands removeKey:aKey ifAbsent:[]
|
2
|
665 |
]
|
0
|
666 |
! !
|
|
667 |
|
|
668 |
!PseudoView methodsFor:'button menus'!
|
|
669 |
|
|
670 |
middleButtonMenu
|
|
671 |
"return the menu associated with the middle mouse button"
|
|
672 |
|
|
673 |
^ middleButtonMenu
|
|
674 |
!
|
|
675 |
|
|
676 |
middleButtonMenu:aMenu
|
|
677 |
"associate aMenu with the middle mouse button"
|
|
678 |
|
|
679 |
middleButtonMenu notNil ifTrue:[
|
72
|
680 |
middleButtonMenu destroy
|
0
|
681 |
].
|
109
|
682 |
middleButtonMenu := aMenu
|
2
|
683 |
!
|
|
684 |
|
|
685 |
setMiddleButtonMenu:aMenu
|
|
686 |
"associate aMenu with the middle mouse button.
|
|
687 |
Do not destroy old menu if any"
|
|
688 |
|
109
|
689 |
middleButtonMenu := aMenu
|
0
|
690 |
! !
|
|
691 |
|
|
692 |
!PseudoView methodsFor:'enable/disable events'!
|
|
693 |
|
|
694 |
enableEvent:anEventSymbol
|
|
695 |
"enable an event -
|
|
696 |
this is a private (internal) method not to be used externally.
|
2
|
697 |
for a list of allowed event symbols see Workstation class"
|
0
|
698 |
|
|
699 |
eventMask := eventMask bitOr:(device eventMaskFor:anEventSymbol).
|
2
|
700 |
drawableId notNil ifTrue:[
|
72
|
701 |
device setEventMask:eventMask in:drawableId
|
0
|
702 |
]
|
|
703 |
!
|
|
704 |
|
|
705 |
disableEvent:anEventSymbol
|
|
706 |
"disable an event -
|
|
707 |
this is a private (internal) method not to be used externally.
|
2
|
708 |
for a list of allowed event symbols see Workstation class"
|
0
|
709 |
|
109
|
710 |
eventMask := eventMask bitAnd:(device eventMaskFor:anEventSymbol) bitInvert.
|
2
|
711 |
drawableId notNil ifTrue:[
|
72
|
712 |
device setEventMask:eventMask in:drawableId
|
0
|
713 |
]
|
|
714 |
!
|
|
715 |
|
54
|
716 |
enableKeyEvents
|
|
717 |
"this is a compatibility leftover -
|
|
718 |
starting with 2.10.3, keyPress is always enabled to allow
|
|
719 |
^C processing."
|
|
720 |
|
|
721 |
!
|
|
722 |
|
0
|
723 |
enableKeyPressEvents
|
54
|
724 |
"this is a compatibility leftover -
|
|
725 |
starting with 2.10.3, keyPress is always enabled to allow
|
|
726 |
^C processing."
|
0
|
727 |
|
|
728 |
!
|
|
729 |
|
|
730 |
enableKeyReleaseEvents
|
|
731 |
"enable key release events"
|
|
732 |
|
|
733 |
self enableEvent:#keyRelease
|
|
734 |
!
|
|
735 |
|
|
736 |
enableButtonPressEvents
|
109
|
737 |
"enable mouse button press events.
|
|
738 |
These are enabled by default anyway."
|
0
|
739 |
|
|
740 |
self enableEvent:#buttonPress
|
|
741 |
!
|
|
742 |
|
|
743 |
enableButtonReleaseEvents
|
109
|
744 |
"enable mouse button release events.
|
|
745 |
These are enabled by default anyway."
|
0
|
746 |
|
|
747 |
self enableEvent:#buttonRelease
|
|
748 |
!
|
|
749 |
|
|
750 |
enableButtonEvents
|
109
|
751 |
"enable both mouse button press and release events.
|
|
752 |
These are enabled by default anyway."
|
0
|
753 |
|
|
754 |
self enableEvent:#buttonPress.
|
|
755 |
self enableEvent:#buttonRelease
|
|
756 |
!
|
|
757 |
|
|
758 |
enableEnterEvents
|
|
759 |
"enable mouse-pointer enter events"
|
|
760 |
|
|
761 |
self enableEvent:#enter
|
|
762 |
!
|
|
763 |
|
|
764 |
enableLeaveEvents
|
|
765 |
"enable mouse-pointer leave events"
|
|
766 |
|
|
767 |
self enableEvent:#leave
|
|
768 |
!
|
|
769 |
|
|
770 |
enableEnterLeaveEvents
|
12
|
771 |
"enable both mouse-pointer enter and leave events"
|
0
|
772 |
|
|
773 |
self enableEvent:#enter.
|
|
774 |
self enableEvent:#leave
|
|
775 |
!
|
|
776 |
|
|
777 |
enableMotionEvents
|
|
778 |
"enable mouse-pointer motion events"
|
|
779 |
|
|
780 |
self enableEvent:#pointerMotion
|
|
781 |
!
|
|
782 |
|
21
|
783 |
compressMotionEvents:aBoolean
|
|
784 |
"enable/disable motion event compression
|
|
785 |
(i.e. replacing all motion events by the last one).
|
|
786 |
Compression makes almost always sense, except when
|
|
787 |
doing things like freehand drawing"
|
|
788 |
|
85
|
789 |
|s|
|
|
790 |
|
|
791 |
(s := self sensor) notNil ifTrue:[
|
|
792 |
s compressMotionEvents:aBoolean
|
|
793 |
]
|
21
|
794 |
!
|
|
795 |
|
0
|
796 |
enableButtonMotionEvents
|
109
|
797 |
"enable mouse-pointer motion-while-button-is-pressed events.
|
|
798 |
These are enabled by default anyway."
|
0
|
799 |
|
|
800 |
self enableEvent:#buttonMotion
|
|
801 |
!
|
|
802 |
|
|
803 |
enableFocusEvents
|
|
804 |
"enable keyboard focus change events"
|
|
805 |
|
|
806 |
self enableEvent:#focusChange
|
|
807 |
!
|
|
808 |
|
|
809 |
disableButtonPressEvents
|
|
810 |
"disable button press events"
|
|
811 |
|
|
812 |
self disableEvent:#buttonPress
|
|
813 |
!
|
|
814 |
|
|
815 |
disableButtonReleaseEvents
|
|
816 |
"disable button release events"
|
|
817 |
|
|
818 |
self disableEvent:#buttonRelease
|
|
819 |
!
|
|
820 |
|
|
821 |
disableButtonEvents
|
|
822 |
"disable all button events"
|
|
823 |
|
|
824 |
self disableEvent:#buttonpress.
|
|
825 |
self disableEvent:#buttonRelease
|
|
826 |
!
|
|
827 |
|
|
828 |
disableMotionEvents
|
|
829 |
"disable motion events"
|
|
830 |
|
|
831 |
self disableEvent:#pointerMotion
|
|
832 |
!
|
|
833 |
|
|
834 |
disableButtonMotionEvents
|
2
|
835 |
"disable button motion-while-button-is-pressed events"
|
0
|
836 |
|
|
837 |
self disableEvent:#buttonMotion
|
12
|
838 |
!
|
|
839 |
|
|
840 |
disableEnterLeaveEvents
|
|
841 |
"disable both mouse-pointer enter and leave events"
|
|
842 |
|
|
843 |
self disableEvent:#enter.
|
|
844 |
self disableEvent:#leave
|
0
|
845 |
! !
|
|
846 |
|
|
847 |
!PseudoView methodsFor:'queries'!
|
|
848 |
|
89
|
849 |
isView
|
|
850 |
"return true, if the receiver is a view"
|
|
851 |
|
|
852 |
^ true
|
|
853 |
!
|
|
854 |
|
0
|
855 |
exposeEventPending
|
89
|
856 |
"return true, if an expose event is pending."
|
0
|
857 |
|
89
|
858 |
|sensor|
|
|
859 |
|
|
860 |
((sensor := self sensor) notNil and:[sensor hasDamageFor:self]) ifTrue:[^ true].
|
0
|
861 |
^ device eventPending:#expose for:drawableId
|
|
862 |
!
|
|
863 |
|
|
864 |
buttonMotionEventPending
|
40
|
865 |
"return true, if a button motion event is pending.
|
|
866 |
Normally, you dont want to use this, since no polling is needed
|
|
867 |
(not even for mouse-tracking).
|
|
868 |
Dont use it, since it does not honor the windowGroup, but
|
|
869 |
goes directly to the device instead.
|
|
870 |
Actually, its a historical leftover"
|
0
|
871 |
|
110
|
872 |
device synchronizeOutput.
|
0
|
873 |
^ device eventPending:#buttonMotion for:drawableId
|
|
874 |
!
|
|
875 |
|
|
876 |
buttonReleaseEventPending
|
40
|
877 |
"return true, if a button release event is pending.
|
|
878 |
Dont use it, since it does not honor the windowGroup, but
|
|
879 |
goes directly to the device instead.
|
|
880 |
Actually, its a historical leftover"
|
0
|
881 |
|
110
|
882 |
device synchronizeOutput.
|
0
|
883 |
^ device eventPending:#buttonRelease for:drawableId
|
|
884 |
! !
|
|
885 |
|
89
|
886 |
!PseudoView methodsFor:'selection handling '!
|
|
887 |
|
|
888 |
selectionClear
|
|
889 |
"someone else has the selection"
|
|
890 |
|
93
|
891 |
"
|
|
892 |
I disabled that; some windowmanagers (programs) seem to clear our
|
|
893 |
selection too often .... (or did I make a mistake somewhere ?)
|
|
894 |
"
|
|
895 |
"/ Smalltalk at:#CopyBuffer put:nil.
|
89
|
896 |
!
|
|
897 |
|
|
898 |
getSelection
|
|
899 |
"return the object selection - either the local one, or the displays
|
|
900 |
selection buffer."
|
|
901 |
|
|
902 |
|sel|
|
|
903 |
|
|
904 |
sel := Smalltalk at:#CopyBuffer.
|
|
905 |
sel isNil ifTrue:[
|
|
906 |
sel := device getSelectionFor:drawableId.
|
|
907 |
sel isNil ifTrue:[^ nil].
|
|
908 |
].
|
|
909 |
^ sel
|
|
910 |
!
|
|
911 |
|
|
912 |
getTextSelection
|
|
913 |
"return the text selection - either the local one, or the displays
|
|
914 |
selection buffer."
|
|
915 |
|
|
916 |
|sel|
|
|
917 |
|
|
918 |
sel := Smalltalk at:#CopyBuffer.
|
|
919 |
sel isNil ifTrue:[
|
|
920 |
sel := device getTextSelectionFor:drawableId.
|
|
921 |
sel isNil ifTrue:[^ nil].
|
|
922 |
].
|
|
923 |
^ sel
|
|
924 |
!
|
|
925 |
|
|
926 |
setTextSelection:something
|
|
927 |
"set the text selection - both the local one, and tell the display
|
|
928 |
that we have changed it."
|
|
929 |
|
|
930 |
|s|
|
|
931 |
|
|
932 |
Smalltalk at:#CopyBuffer put:something.
|
|
933 |
s := something.
|
|
934 |
s isString ifFalse:[
|
102
|
935 |
s := s asStringWithCRsFrom:1 to:(s size) compressTabs:false withCR:false
|
89
|
936 |
].
|
|
937 |
(device setTextSelection:s owner:drawableId) ifFalse:[
|
|
938 |
'selection failed' errorPrintNL
|
|
939 |
]
|
|
940 |
!
|
|
941 |
|
|
942 |
setSelection:something
|
|
943 |
"set the object selection - both the local one, and tell the display
|
|
944 |
that we have changed it."
|
|
945 |
|
|
946 |
Smalltalk at:#CopyBuffer put:something.
|
|
947 |
(device setSelection:something owner:drawableId) ifFalse:[
|
|
948 |
'selection failed' errorPrintNL
|
|
949 |
]
|
|
950 |
!
|
|
951 |
|
|
952 |
selectionRequest:propertyID target:targetID selection:selectionID from:windowID
|
|
953 |
"someone asks for our selection"
|
|
954 |
|
|
955 |
|o s stream|
|
|
956 |
|
|
957 |
o := Smalltalk at:#CopyBuffer.
|
|
958 |
targetID == (device atomIDOf:'STRING') ifTrue:[
|
|
959 |
s := o.
|
|
960 |
o isString ifFalse:[
|
|
961 |
o isNil ifTrue:[
|
|
962 |
s := ''
|
|
963 |
] ifFalse:[
|
95
|
964 |
(o isKindOf:StringCollection) ifTrue:[
|
102
|
965 |
s := o asStringWithCRsFrom:1 to:(o size) compressTabs:false withCR:false
|
89
|
966 |
] ifFalse:[
|
|
967 |
s := o storeString
|
|
968 |
]
|
|
969 |
]
|
|
970 |
].
|
|
971 |
device
|
|
972 |
sendSelection:s
|
|
973 |
property:propertyID
|
|
974 |
target:targetID
|
|
975 |
to:windowID
|
|
976 |
] ifFalse:[
|
|
977 |
stream := WriteStream on:(ByteArray new:200).
|
|
978 |
o storeBinaryOn:stream.
|
|
979 |
device
|
|
980 |
sendSelection:(stream contents)
|
|
981 |
property:propertyID
|
|
982 |
target:(device atomIDOf:'ST_OBJECT' create:true)
|
|
983 |
to:windowID
|
|
984 |
]
|
|
985 |
!
|
|
986 |
|
|
987 |
selectionNotify:propertyID target:targetID selection:selectionID from:windowID
|
|
988 |
"this is sent from the server as a reply to a request for a
|
|
989 |
selection. The view should be prepared to paste the received
|
|
990 |
string (it asked for it so that should not be a problem)"
|
|
991 |
|
|
992 |
|s|
|
|
993 |
|
|
994 |
targetID == (device atomIDOf:'STRING') ifTrue:[
|
|
995 |
"
|
|
996 |
a returned string
|
|
997 |
"
|
|
998 |
s := device getTextProperty:propertyID from:windowID.
|
|
999 |
s notNil ifTrue:[
|
|
1000 |
(s endsWith:Character cr) ifTrue:[
|
95
|
1001 |
self paste:(s asStringCollection copyWith:'')
|
89
|
1002 |
] ifFalse:[
|
|
1003 |
self paste:s
|
|
1004 |
]
|
|
1005 |
]
|
|
1006 |
] ifFalse:[
|
|
1007 |
"
|
|
1008 |
a returned object
|
|
1009 |
"
|
|
1010 |
s := device getObjectProperty:propertyID from:windowID.
|
|
1011 |
s notNil ifTrue:[
|
|
1012 |
self paste:s
|
|
1013 |
]
|
|
1014 |
]
|
|
1015 |
! !
|
|
1016 |
|
0
|
1017 |
!PseudoView methodsFor:'event handling'!
|
|
1018 |
|
28
|
1019 |
catchExpose
|
54
|
1020 |
"this MUST be sent BEFORE doing a bit-blt copy (i.e. copyFrom...),
|
|
1021 |
to tell the sensor that incoming expose events are to be remembered.
|
|
1022 |
Sometime after the bit-blt, waitForExpose should be sent, to finally
|
|
1023 |
suspend until the expose/noExpose event arrives.
|
|
1024 |
This may be an X speciality and be reimplemented to handle devices
|
|
1025 |
which do not need this kind of asynchronous bit-blt confirmation.
|
|
1026 |
"
|
28
|
1027 |
|
|
1028 |
|wg|
|
|
1029 |
|
54
|
1030 |
gotExpose := false.
|
28
|
1031 |
wg := self windowGroup.
|
|
1032 |
wg notNil ifTrue:[
|
72
|
1033 |
"
|
|
1034 |
must process eny pending expose events, since
|
|
1035 |
usually the origin is changed soon so that previous
|
|
1036 |
expose events coordinates are invalid
|
|
1037 |
"
|
|
1038 |
wg processExposeEvents.
|
|
1039 |
wg sensor catchExpose
|
28
|
1040 |
]
|
|
1041 |
!
|
|
1042 |
|
0
|
1043 |
waitForExpose
|
|
1044 |
"wait until an expose event arrives (to wait for scroll-finish)"
|
|
1045 |
|
26
|
1046 |
|wg|
|
|
1047 |
|
|
1048 |
wg := self windowGroup.
|
54
|
1049 |
wg notNil ifTrue:[
|
72
|
1050 |
"
|
|
1051 |
a normal (suspendable) view.
|
|
1052 |
wait by doing a real wait
|
|
1053 |
"
|
|
1054 |
wg waitForExposeFor:self
|
54
|
1055 |
] ifFalse:[
|
72
|
1056 |
"
|
|
1057 |
a pure event driven view.
|
|
1058 |
wait by doing a direct dispatch loop until the event arrives.
|
|
1059 |
"
|
|
1060 |
[gotExpose] whileFalse:[
|
|
1061 |
device dispatchExposeEventFor:drawableId
|
|
1062 |
].
|
0
|
1063 |
]
|
|
1064 |
!
|
|
1065 |
|
|
1066 |
noExpose
|
54
|
1067 |
"a no expose event after a scroll (event-mode only)"
|
0
|
1068 |
|
|
1069 |
exposePending := false.
|
|
1070 |
gotExpose := true
|
|
1071 |
!
|
|
1072 |
|
83
|
1073 |
deviceGraphicExposeX:x y:y width:w height:h
|
77
|
1074 |
"this is the low-level (untransformed) event as received
|
83
|
1075 |
from the device (i.e. coordinates are in device coordinates).
|
|
1076 |
If there is a transformation, apply the inverse
|
77
|
1077 |
and send a graphicExpose with the logical coordinates."
|
|
1078 |
|
|
1079 |
|lx ly lw lh|
|
|
1080 |
|
|
1081 |
lx := x.
|
|
1082 |
ly := y.
|
|
1083 |
lw := w.
|
|
1084 |
lh := h.
|
|
1085 |
transformation notNil ifTrue:[
|
|
1086 |
lx := transformation applyInverseToX:lx.
|
|
1087 |
ly := transformation applyInverseToY:ly.
|
|
1088 |
lw := transformation applyInverseScaleX:lw.
|
|
1089 |
lh := transformation applyInverseScaleY:lh.
|
|
1090 |
].
|
|
1091 |
self graphicExposeX:lx y:ly width:lw height:lh
|
|
1092 |
!
|
|
1093 |
|
83
|
1094 |
deviceExposeX:x y:y width:w height:h
|
77
|
1095 |
"this is the low-level (untransformed) event as received
|
83
|
1096 |
from the device (i.e. coordinates are in device coordinates).
|
|
1097 |
If there is a transformation, apply the inverse
|
77
|
1098 |
and send an expose with the logical coordinates."
|
|
1099 |
|
|
1100 |
|lx ly lw lh|
|
|
1101 |
|
|
1102 |
lx := x.
|
|
1103 |
ly := y.
|
|
1104 |
lw := w.
|
|
1105 |
lh := h.
|
|
1106 |
transformation notNil ifTrue:[
|
|
1107 |
lx := transformation applyInverseToX:lx.
|
|
1108 |
ly := transformation applyInverseToY:ly.
|
|
1109 |
lw := transformation applyInverseScaleX:lw.
|
|
1110 |
lh := transformation applyInverseScaleY:lh.
|
|
1111 |
].
|
|
1112 |
self exposeX:lx y:ly width:lw height:lh
|
|
1113 |
!
|
|
1114 |
|
83
|
1115 |
deviceKeyPress:key x:x y:y
|
77
|
1116 |
"this is the low-level (untransformed) event as received
|
83
|
1117 |
from the device (i.e. coordinates are in device coordinates).
|
|
1118 |
If there is a transformation, apply the inverse
|
77
|
1119 |
and send a keyPress with the logical coordinates."
|
|
1120 |
|
|
1121 |
|lx ly|
|
|
1122 |
|
|
1123 |
lx := x.
|
|
1124 |
ly := y.
|
|
1125 |
transformation notNil ifTrue:[
|
|
1126 |
lx := transformation applyInverseToX:lx.
|
|
1127 |
ly := transformation applyInverseToY:ly.
|
|
1128 |
].
|
|
1129 |
self keyPress:key x:lx y:ly
|
|
1130 |
!
|
|
1131 |
|
83
|
1132 |
deviceKeyRelease:key x:x y:y
|
77
|
1133 |
"this is the low-level (untransformed) event as received
|
83
|
1134 |
from the device (i.e. coordinates are in device coordinates).
|
|
1135 |
If there is a transformation, apply the inverse
|
77
|
1136 |
and send a keyRelease with the logical coordinates."
|
|
1137 |
|
|
1138 |
|lx ly|
|
|
1139 |
|
|
1140 |
lx := x.
|
|
1141 |
ly := y.
|
|
1142 |
transformation notNil ifTrue:[
|
|
1143 |
lx := transformation applyInverseToX:lx.
|
|
1144 |
ly := transformation applyInverseToY:ly.
|
|
1145 |
].
|
|
1146 |
self keyRelease:key x:lx y:ly
|
|
1147 |
!
|
|
1148 |
|
83
|
1149 |
deviceButtonPress:butt x:x y:y
|
77
|
1150 |
"this is the low-level (untransformed) event as received
|
83
|
1151 |
from the device (i.e. coordinates are in device coordinates).
|
|
1152 |
If there is a transformation, apply the inverse
|
77
|
1153 |
and send a buttonPress with the logical coordinates."
|
|
1154 |
|
|
1155 |
|lx ly|
|
|
1156 |
|
|
1157 |
lx := x.
|
|
1158 |
ly := y.
|
|
1159 |
transformation notNil ifTrue:[
|
|
1160 |
lx := transformation applyInverseToX:lx.
|
|
1161 |
ly := transformation applyInverseToY:ly.
|
|
1162 |
].
|
|
1163 |
self buttonPress:butt x:lx y:ly
|
|
1164 |
!
|
|
1165 |
|
83
|
1166 |
deviceButtonRelease:butt x:x y:y
|
77
|
1167 |
"this is the low-level (untransformed) event as received
|
83
|
1168 |
from the device (i.e. coordinates are in device coordinates).
|
|
1169 |
If there is a transformation, apply the inverse
|
77
|
1170 |
and send a buttonRelease with the logical coordinates."
|
|
1171 |
|
|
1172 |
|lx ly|
|
|
1173 |
|
|
1174 |
lx := x.
|
|
1175 |
ly := y.
|
|
1176 |
transformation notNil ifTrue:[
|
|
1177 |
lx := transformation applyInverseToX:lx.
|
|
1178 |
ly := transformation applyInverseToY:ly.
|
|
1179 |
].
|
|
1180 |
self buttonRelease:butt x:lx y:ly
|
|
1181 |
!
|
|
1182 |
|
83
|
1183 |
deviceButtonShiftPress:butt x:x y:y
|
77
|
1184 |
"this is the low-level (untransformed) event as received
|
83
|
1185 |
from the device (i.e. coordinates are in device coordinates).
|
|
1186 |
If there is a transformation, apply the inverse
|
77
|
1187 |
and send a buttonShiftPress with the logical coordinates."
|
|
1188 |
|
|
1189 |
|lx ly|
|
|
1190 |
|
|
1191 |
lx := x.
|
|
1192 |
ly := y.
|
|
1193 |
transformation notNil ifTrue:[
|
|
1194 |
lx := transformation applyInverseToX:lx.
|
|
1195 |
ly := transformation applyInverseToY:ly.
|
|
1196 |
].
|
|
1197 |
self buttonShiftPress:butt x:lx y:ly
|
|
1198 |
!
|
|
1199 |
|
83
|
1200 |
deviceButtonMultiPress:butt x:x y:y
|
77
|
1201 |
"this is the low-level (untransformed) event as received
|
83
|
1202 |
from the device (i.e. coordinates are in device coordinates).
|
|
1203 |
If there is a transformation, apply the inverse
|
77
|
1204 |
and send a buttonMultiPress with the logical coordinates."
|
|
1205 |
|
|
1206 |
|lx ly|
|
|
1207 |
|
|
1208 |
lx := x.
|
|
1209 |
ly := y.
|
|
1210 |
transformation notNil ifTrue:[
|
|
1211 |
lx := transformation applyInverseToX:lx.
|
|
1212 |
ly := transformation applyInverseToY:ly.
|
|
1213 |
].
|
|
1214 |
self buttonMultiPress:butt x:lx y:ly
|
|
1215 |
!
|
|
1216 |
|
83
|
1217 |
deviceButtonMotion:state x:x y:y
|
77
|
1218 |
"this is the low-level (untransformed) event as received
|
83
|
1219 |
from the device (i.e. coordinates are in device coordinates).
|
|
1220 |
If there is a transformation, apply the inverse
|
77
|
1221 |
and send a buttonMotion with the logical coordinates."
|
|
1222 |
|
|
1223 |
|lx ly|
|
|
1224 |
|
|
1225 |
lx := x.
|
|
1226 |
ly := y.
|
|
1227 |
transformation notNil ifTrue:[
|
|
1228 |
lx := transformation applyInverseToX:lx.
|
|
1229 |
ly := transformation applyInverseToY:ly.
|
|
1230 |
].
|
|
1231 |
self buttonMotion:state x:lx y:ly
|
|
1232 |
!
|
|
1233 |
|
83
|
1234 |
devicePointerEnter:state x:x y:y
|
77
|
1235 |
"this is the low-level (untransformed) event as received
|
83
|
1236 |
from the device (i.e. coordinates are in device coordinates).
|
|
1237 |
If there is a transformation, apply the inverse
|
77
|
1238 |
and send a pointerEnter with the logical coordinates."
|
|
1239 |
|
|
1240 |
|lx ly|
|
|
1241 |
|
|
1242 |
lx := x.
|
|
1243 |
ly := y.
|
|
1244 |
transformation notNil ifTrue:[
|
|
1245 |
lx := transformation applyInverseToX:lx.
|
|
1246 |
ly := transformation applyInverseToY:ly.
|
|
1247 |
].
|
|
1248 |
self pointerEnter:state x:lx y:ly
|
|
1249 |
!
|
|
1250 |
|
0
|
1251 |
graphicExposeX:x y:y width:w height:h
|
54
|
1252 |
"an expose event after a scroll - do normal redraw processing"
|
0
|
1253 |
|
|
1254 |
self exposeX:x y:y width:w height:h
|
|
1255 |
!
|
|
1256 |
|
|
1257 |
exposeX:x y:y width:w height:h
|
|
1258 |
"an expose event - nothing done here"
|
|
1259 |
|
|
1260 |
^ self
|
|
1261 |
!
|
|
1262 |
|
|
1263 |
keyPress:key x:x y:y
|
54
|
1264 |
"a key was pressed in this view.
|
|
1265 |
Here only keyCommands are handled - more action has to
|
0
|
1266 |
be implemented by redefining this method"
|
|
1267 |
|
|
1268 |
|action|
|
|
1269 |
|
|
1270 |
keyCommands notNil ifTrue:[
|
72
|
1271 |
action := keyCommands at:key ifAbsent:[nil].
|
|
1272 |
action notNil ifTrue:[
|
|
1273 |
action value
|
|
1274 |
]
|
0
|
1275 |
]
|
|
1276 |
!
|
|
1277 |
|
|
1278 |
keyRelease:key x:x y:y
|
|
1279 |
"default action is to do nothing"
|
|
1280 |
|
|
1281 |
^ self
|
|
1282 |
!
|
|
1283 |
|
|
1284 |
buttonShiftPress:button x:x y:y
|
|
1285 |
"button was pressed with shift - default to unshift-press action"
|
|
1286 |
|
|
1287 |
^ self buttonPress:button x:x y:y
|
|
1288 |
!
|
|
1289 |
|
|
1290 |
buttonPress:button x:x y:y
|
|
1291 |
"button was pressed - if its middle button and there is a menu,
|
|
1292 |
show it."
|
|
1293 |
|
46
|
1294 |
((button == 2) or:[button == #menu]) ifTrue:[
|
72
|
1295 |
middleButtonMenu notNil ifTrue:[
|
|
1296 |
middleButtonMenu showAtPointer
|
|
1297 |
]
|
0
|
1298 |
]
|
|
1299 |
!
|
|
1300 |
|
|
1301 |
buttonMultiPress:button x:x y:y
|
|
1302 |
"button was pressed fast after previous press - default to press-again"
|
|
1303 |
|
|
1304 |
^ self buttonPress:button x:x y:y
|
|
1305 |
!
|
|
1306 |
|
|
1307 |
buttonRelease:button x:x y:y
|
|
1308 |
"button was released - do nothing here"
|
|
1309 |
|
|
1310 |
^ self
|
|
1311 |
!
|
|
1312 |
|
|
1313 |
buttonMotion:state x:x y:y
|
|
1314 |
"mouse was moved while button is pressed - do nothing here"
|
|
1315 |
|
|
1316 |
^ self
|
|
1317 |
!
|
|
1318 |
|
|
1319 |
focusIn
|
|
1320 |
"got keayboard focus - do nothing here"
|
|
1321 |
|
|
1322 |
^ self
|
|
1323 |
!
|
|
1324 |
|
|
1325 |
focusOut
|
|
1326 |
"lost keayboard focus - do nothing here"
|
|
1327 |
|
|
1328 |
^ self
|
|
1329 |
!
|
|
1330 |
|
|
1331 |
pointerEnter:state x:x y:y
|
|
1332 |
"mouse cursor entered view - do nothing here"
|
|
1333 |
|
|
1334 |
^ self
|
|
1335 |
!
|
|
1336 |
|
|
1337 |
pointerLeave:state
|
|
1338 |
"mouse cursor left view - do nothing here"
|
|
1339 |
|
|
1340 |
^ self
|
31
|
1341 |
!
|
|
1342 |
|
|
1343 |
resizeRequest
|
|
1344 |
^ self
|
0
|
1345 |
! !
|
2
|
1346 |
|
|
1347 |
!PseudoView methodsFor: 'binary storage'!
|
|
1348 |
|
|
1349 |
readBinaryContentsFrom: stream manager: manager
|
40
|
1350 |
"tell the newly restored View to recreate itself.
|
89
|
1351 |
Bug: restored view seems to loose its position (if its not an StdSysView)."
|
2
|
1352 |
|
|
1353 |
super readBinaryContentsFrom: stream manager: manager.
|
|
1354 |
|
|
1355 |
gcId := nil.
|
|
1356 |
drawableId := nil.
|
|
1357 |
self recreate.
|
|
1358 |
realized ifTrue:[
|
72
|
1359 |
self rerealize
|
2
|
1360 |
]
|
40
|
1361 |
|
|
1362 |
"
|
|
1363 |
|s|
|
|
1364 |
s := 'storedLabel.boss' asFilename writeStream binary.
|
|
1365 |
(Label label:'hello there') realize storeBinaryOn:s.
|
|
1366 |
s close.
|
|
1367 |
"
|
|
1368 |
|
|
1369 |
"
|
|
1370 |
|s|
|
|
1371 |
s := 'storedLabel.boss' asFilename readStream binary.
|
|
1372 |
(Object readBinaryFrom:s)
|
|
1373 |
"
|
2
|
1374 |
! !
|