26
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
3 |
All Rights Reserved
|
26
|
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 |
"
|
11
|
12 |
|
|
13 |
Object subclass:#WindowEvent
|
72
|
14 |
instanceVariableNames:'view type arguments'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Interface-Support'
|
11
|
18 |
!
|
|
19 |
|
54
|
20 |
WindowEvent comment:'
|
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
22 |
All Rights Reserved
|
54
|
23 |
|
84
|
24 |
$Header: /cvs/stx/stx/libview/WindowEvent.st,v 1.10 1994-11-22 14:32:22 claus Exp $
|
54
|
25 |
'!
|
|
26 |
|
46
|
27 |
!WindowEvent class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
72
|
32 |
All Rights Reserved
|
46
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
|
42 |
|
|
43 |
version
|
|
44 |
"
|
84
|
45 |
$Header: /cvs/stx/stx/libview/WindowEvent.st,v 1.10 1994-11-22 14:32:22 claus Exp $
|
46
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
Instances of WindowEvent are created for every event coming from
|
72
|
52 |
the graphics device, to be handled by a windowGroup.
|
|
53 |
Usually, they are queued by a sensor, and processed in some event loop
|
|
54 |
in the window group.
|
46
|
55 |
"
|
|
56 |
! !
|
|
57 |
|
11
|
58 |
!WindowEvent class methodsFor:'instance creation'!
|
|
59 |
|
|
60 |
for:aView type:aSymbol arguments:argArray
|
|
61 |
"create and return a new windowEvent for sending
|
|
62 |
aSymbol-message with arguments to aView"
|
|
63 |
|
46
|
64 |
^ (self new) for:aView type:aSymbol arguments:argArray
|
|
65 |
!
|
|
66 |
|
72
|
67 |
for:aView type:aSymbol
|
|
68 |
"create and return a new windowEvent for sending
|
|
69 |
aSymbol-message with no arguments to aView"
|
|
70 |
|
|
71 |
^ (self new) for:aView type:aSymbol arguments:#()
|
|
72 |
!
|
|
73 |
|
46
|
74 |
damageFor:aView rectangle:aRectangle
|
|
75 |
"create and return a new damage Event for aRectangle
|
|
76 |
in aView"
|
|
77 |
|
|
78 |
^ (self new) for:aView type:#damage arguments:aRectangle
|
|
79 |
|
11
|
80 |
! !
|
|
81 |
|
72
|
82 |
!WindowEvent methodsFor:'queries'!
|
|
83 |
|
|
84 |
isKeyEvent
|
|
85 |
"return true, if this event is a keyboard event"
|
|
86 |
|
|
87 |
^ (type == #keyPress:x:y) or:[type == #keyRelease:x:y]
|
|
88 |
!
|
|
89 |
|
|
90 |
isDamage
|
|
91 |
"return true, if this is a damage event"
|
|
92 |
|
|
93 |
^ type == #damage
|
|
94 |
! !
|
|
95 |
|
28
|
96 |
!WindowEvent methodsFor:'accessing'!
|
|
97 |
|
|
98 |
view
|
|
99 |
"return the view, for which the event is for"
|
|
100 |
|
|
101 |
^ view
|
|
102 |
!
|
|
103 |
|
72
|
104 |
view:aView
|
|
105 |
"set the view, for which the event is for"
|
|
106 |
|
|
107 |
view := aView
|
|
108 |
!
|
|
109 |
|
28
|
110 |
type
|
|
111 |
"return the type of the event"
|
|
112 |
|
|
113 |
^ type
|
|
114 |
!
|
|
115 |
|
|
116 |
arguments
|
|
117 |
"return the arguments of the event"
|
|
118 |
|
|
119 |
^ arguments
|
|
120 |
!
|
|
121 |
|
|
122 |
arguments:anArray
|
|
123 |
"set the arguments"
|
|
124 |
|
|
125 |
arguments := anArray
|
46
|
126 |
!
|
|
127 |
|
|
128 |
rectangle
|
|
129 |
"return the damage rectangle"
|
|
130 |
|
|
131 |
^ arguments "consider this a kludge"
|
28
|
132 |
! !
|
|
133 |
|
11
|
134 |
!WindowEvent methodsFor:'sending'!
|
|
135 |
|
|
136 |
sendEvent
|
81
|
137 |
"forward the event represented by the receiver to the delegate,
|
|
138 |
the controller or the view.
|
78
|
139 |
Delegated messages get the original view as an extra argument."
|
11
|
140 |
|
81
|
141 |
|delegate selector eventReceiver controller|
|
11
|
142 |
|
78
|
143 |
selector := type.
|
|
144 |
delegate := view delegate.
|
|
145 |
delegate notNil ifTrue:[
|
|
146 |
"
|
|
147 |
what a kludge - sending to delegate needs another
|
|
148 |
selector and an additional argument.
|
|
149 |
have to edit the selector ...
|
|
150 |
"
|
|
151 |
(selector endsWith:':') ifTrue:[
|
|
152 |
selector := (selector , 'view:') asSymbol.
|
|
153 |
] ifFalse:[
|
|
154 |
selector := (selector , 'View:') asSymbol.
|
|
155 |
].
|
|
156 |
arguments isNil ifTrue:[
|
|
157 |
delegate perform:selector with:view
|
72
|
158 |
] ifFalse:[
|
78
|
159 |
delegate perform:selector withArguments:(arguments copyWith:view)
|
72
|
160 |
]
|
78
|
161 |
] ifFalse:[
|
|
162 |
"
|
81
|
163 |
another one:
|
|
164 |
if the view has a transformation, edit the selector
|
84
|
165 |
from #foo to #deviceFoo...
|
78
|
166 |
This allows the view to handle the event either in device or
|
84
|
167 |
logical coordinates. (since the deviceFoo-messages default implementation
|
78
|
168 |
in PseudoView translates and resends).
|
84
|
169 |
Actually, I could always send deviceXXX without speed penalty
|
81
|
170 |
(event sending is no high frequency operation), but that just adds
|
|
171 |
another context to any debuggers walkback, making things less clear.
|
78
|
172 |
"
|
81
|
173 |
eventReceiver := view.
|
|
174 |
(controller := view controller) notNil ifTrue:[
|
|
175 |
(#(
|
|
176 |
#'buttonPress:x:y:'
|
78
|
177 |
#'buttonRelease:x:y:'
|
|
178 |
#'buttonShiftPress:x:y:'
|
|
179 |
#'buttonMultiPress:x:y:'
|
81
|
180 |
#'buttonMotion:x:y:'
|
78
|
181 |
#'keyPress:x:y:'
|
|
182 |
#'keyRelease:x:y:'
|
81
|
183 |
#'exposeX:y:width:height:'
|
|
184 |
#'graphicExposeX:y:width:height:'
|
|
185 |
#'pointerEnter:x:y:'
|
|
186 |
) includes:selector) ifTrue:[
|
|
187 |
eventReceiver := controller.
|
|
188 |
]
|
|
189 |
].
|
|
190 |
|
|
191 |
view transformation notNil ifTrue:[
|
|
192 |
(#(
|
|
193 |
#'buttonPress:x:y:'
|
|
194 |
#'buttonRelease:x:y:'
|
|
195 |
#'buttonShiftPress:x:y:'
|
|
196 |
#'buttonMultiPress:x:y:'
|
|
197 |
#'buttonMotion:x:y:'
|
|
198 |
#'keyPress:x:y:'
|
|
199 |
#'keyRelease:x:y:'
|
|
200 |
#'exposeX:y:width:height:'
|
|
201 |
#'graphicExposeX:y:width:height:'
|
|
202 |
#'pointerEnter:x:y:'
|
|
203 |
)includes:selector) ifTrue:[
|
78
|
204 |
selector := selector asString.
|
|
205 |
selector at:1 put:(selector at:1) asUppercase.
|
84
|
206 |
selector := ('device' , selector) asSymbol
|
78
|
207 |
]
|
|
208 |
].
|
81
|
209 |
eventReceiver perform:selector withArguments:arguments
|
78
|
210 |
]
|
11
|
211 |
! !
|
|
212 |
|
|
213 |
!WindowEvent methodsFor:'private accessing'!
|
|
214 |
|
|
215 |
for:aView type:aSymbol arguments:argArray
|
|
216 |
"set the instances of the window event"
|
|
217 |
|
|
218 |
view := aView.
|
|
219 |
type := aSymbol.
|
|
220 |
arguments := argArray
|
|
221 |
! !
|