author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 06 Sep 2017 09:47:50 +0200 | |
branch | jv |
changeset 8179 | ced410b68993 |
parent 7366 | 18c5cd709f5c |
child 8420 | 76e39223f5ab |
permissions | -rw-r--r-- |
1282 | 1 |
" |
1283 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
3 |
All Rights Reserved |
1282 | 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 |
" |
|
3198 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
7357 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1282 | 16 |
Object subclass:#GraphicsDevice |
7166
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
17 |
instanceVariableNames:'displayId screen eventListeners deviceType graphicsContextClass' |
1282 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Graphics' |
|
21 |
! |
|
22 |
||
7166
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
23 |
GraphicsDevice class instanceVariableNames:'graphicsContextClass' |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
24 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
25 |
" |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
26 |
No other class instance variables are inherited by this class. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
27 |
" |
7365 | 28 |
|
29 |
! |
|
7357 | 30 |
AllocationFailure subclass:#GraphicResourceAllocationFailure |
31 |
instanceVariableNames:'' |
|
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:GraphicsDevice |
|
35 |
! |
|
36 |
||
1282 | 37 |
!GraphicsDevice class methodsFor:'documentation'! |
38 |
||
39 |
copyright |
|
40 |
" |
|
1283 | 41 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
42 |
All Rights Reserved |
1282 | 43 |
|
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
" |
|
51 |
||
52 |
! |
|
53 |
||
54 |
documentation |
|
55 |
" |
|
56 |
this abstract class was inserted to provide a home for ST-80 classes |
|
57 |
(previously, DeviceWorkstation was directly under Object). |
|
58 |
||
1283 | 59 |
In ST/X, this is mostly dummy. |
60 |
||
1282 | 61 |
[instance variables:] |
3443 | 62 |
displayId <Handle> the device handle |
63 |
screen any another some device specific id |
|
64 |
eventListeners <Collection> | nil bunch of objects interested in events. |
|
65 |
deviceType <Symbol> some arbitrary symbol, used to choose windowSpecs. |
|
1282 | 66 |
|
67 |
[see also:] |
|
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
68 |
DeviceWorkstation XWorkstation |
1282 | 69 |
|
70 |
[author:] |
|
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
71 |
Claus Gittinger |
1282 | 72 |
" |
73 |
||
74 |
! ! |
|
75 |
||
7166
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
76 |
!GraphicsDevice class methodsFor:'accessing'! |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
77 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
78 |
graphicsContextClass |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
79 |
"Return a graphics context class to use for this graphics device type. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
80 |
Default is to use DeviceGraphicsContext" |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
81 |
^ graphicsContextClass ? DeviceGraphicsContext |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
82 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
83 |
"Modified (comment): / 25-02-2016 / 07:30:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
84 |
! |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
85 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
86 |
graphicsContextClass:aClass |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
87 |
"Set a graphics context class to use for this graphics device type. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
88 |
Usually there's no need set this, just stich with defaults." |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
89 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
90 |
graphicsContextClass := aClass. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
91 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
92 |
"Modified (comment): / 25-02-2016 / 07:30:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
93 |
! ! |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
94 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
95 |
!GraphicsDevice methodsFor:'accessing'! |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
96 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
97 |
graphicsContextClass |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
98 |
"Return a graphics context class to use for this device. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
99 |
Default is to use DeviceGraphicsContext" |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
100 |
graphicsContextClass isNil ifTrue:[ |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
101 |
graphicsContextClass := self class graphicsContextClass. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
102 |
]. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
103 |
^ graphicsContextClass |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
104 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
105 |
"Modified: / 25-02-2016 / 07:31:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
106 |
! |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
107 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
108 |
graphicsContextClass:aClass |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
109 |
"Set a graphics context class to use for this device. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
110 |
Usually there's no need set this, just stich with defaults." |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
111 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
112 |
graphicsContextClass := aClass. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
113 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
114 |
"Modified (comment): / 25-02-2016 / 07:26:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
115 |
! ! |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
116 |
|
3445 | 117 |
!GraphicsDevice methodsFor:'accessing & queries'! |
3198 | 118 |
|
119 |
addEventListener:aListener |
|
120 |
"add a local eventListener (with new protocol - #processEvent:) |
|
121 |
This one gets a chance to intercept all events for this device" |
|
122 |
||
123 |
eventListeners isNil ifTrue:[ |
|
3488 | 124 |
eventListeners := OrderedCollection new:2 |
3198 | 125 |
]. |
3488 | 126 |
(eventListeners includesIdentical:aListener) ifFalse:[ |
127 |
eventListeners add:aListener |
|
128 |
]. |
|
3198 | 129 |
! |
130 |
||
3445 | 131 |
bePDA |
132 |
self deviceType:#pda |
|
3443 | 133 |
! |
3198 | 134 |
|
3443 | 135 |
deviceType |
136 |
^ deviceType |
|
137 |
! |
|
3198 | 138 |
|
3443 | 139 |
deviceType:aSymbol |
140 |
deviceType := aSymbol |
|
3445 | 141 |
! |
142 |
||
143 |
isPDA |
|
144 |
^ self deviceType == #pda |
|
145 |
! |
|
146 |
||
5561 | 147 |
isWebServiceDevice |
148 |
"I am not a WebService pseude-device" |
|
149 |
||
150 |
^ false |
|
151 |
! |
|
152 |
||
3445 | 153 |
removeEventListener:aListener |
154 |
"remove a local eventListener (with new protocol - #processEvent:)" |
|
155 |
||
156 |
eventListeners notNil ifTrue:[ |
|
157 |
eventListeners removeIdentical:aListener ifAbsent:nil |
|
158 |
]. |
|
3198 | 159 |
! ! |
160 |
||
6220 | 161 |
!GraphicsDevice methodsFor:'creating graphics contexts'! |
162 |
||
163 |
newGraphicsContextFor:aGraphicsMedium |
|
164 |
"create a new graphics context. |
|
165 |
The defaults is to use the inherited graphics context. |
|
166 |
Subclasses may redefine this to use their own graphics context" |
|
167 |
||
6357 | 168 |
|gc| |
169 |
||
170 |
GraphicsMedium superclass == DeviceGraphicsContext ifTrue:[ |
|
171 |
"this is for transition to delegatest GC" |
|
172 |
^ aGraphicsMedium. |
|
173 |
]. |
|
7166
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
174 |
graphicsContextClass isNil ifTrue:[ |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
175 |
graphicsContextClass := self class graphicsContextClass. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
176 |
]. |
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
177 |
gc := graphicsContextClass onDevice:self. |
6357 | 178 |
gc font:aGraphicsMedium class defaultFont. |
179 |
^ gc. |
|
7166
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
180 |
|
1f7489fd814e
Allow to configure a graphics context class to use with given graphics device type
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6357
diff
changeset
|
181 |
"Modified: / 25-02-2016 / 07:32:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6220 | 182 |
! ! |
183 |
||
3198 | 184 |
!GraphicsDevice methodsFor:'event processing'! |
185 |
||
186 |
notifyEventListenersAbout:anEvent |
|
187 |
"notify all eventHandlers about an incoming event. |
|
188 |
If any returns true, it is assumed to be eaten by the handler and not |
|
189 |
enqueued (i.e. not passed to the windowGroup process)" |
|
190 |
||
191 |
|anyListenerReturnedTrue| |
|
192 |
||
193 |
anyListenerReturnedTrue := false. |
|
194 |
||
195 |
"/ local listeners ... |
|
196 |
eventListeners notNil ifTrue:[ |
|
7362 | 197 |
eventListeners do:[:aListener | |
198 |
"/ notice: evaluating or here; all listeners get a chance |
|
199 |
anyListenerReturnedTrue := anyListenerReturnedTrue | |
|
200 |
(aListener processEvent:anEvent) |
|
201 |
] |
|
3198 | 202 |
]. |
203 |
||
204 |
^ anyListenerReturnedTrue. |
|
205 |
! ! |
|
206 |
||
3577 | 207 |
!GraphicsDevice methodsFor:'misc'! |
208 |
||
209 |
roundTripTime |
|
210 |
"answer the round trip time in milliseconds. |
|
5561 | 211 |
May be used to detect slow device connections. |
3577 | 212 |
Subclasses redefine this. Assume a fast Diplay connection |
213 |
and answer 0 here" |
|
214 |
||
215 |
^ 0 |
|
216 |
||
217 |
" |
|
218 |
Screen current roundTripTime |
|
219 |
" |
|
220 |
! ! |
|
221 |
||
7357 | 222 |
!GraphicsDevice::GraphicResourceAllocationFailure class methodsFor:'documentation'! |
223 |
||
224 |
copyright |
|
225 |
" |
|
226 |
COPYRIGHT (c) 2016 by eXept Software AG |
|
227 |
All Rights Reserved |
|
228 |
||
229 |
This software is furnished under a license and may be used |
|
230 |
only in accordance with the terms of that license and with the |
|
231 |
inclusion of the above copyright notice. This software may not |
|
232 |
be provided or otherwise made available to, or used by, any |
|
233 |
other person. No title to or ownership of the software is |
|
234 |
hereby transferred. |
|
235 |
" |
|
236 |
! |
|
237 |
||
238 |
documentation |
|
239 |
" |
|
240 |
raised when allocation of a graphics resource (pixmap, bitmap, cursor, font, etc.) |
|
241 |
fails. |
|
242 |
" |
|
243 |
! ! |
|
244 |
||
245 |
!GraphicsDevice::GraphicResourceAllocationFailure class methodsFor:'queries'! |
|
246 |
||
247 |
defaultAnswer |
|
248 |
^ nil |
|
249 |
! |
|
250 |
||
251 |
isQuerySignal |
|
252 |
^ true |
|
253 |
! ! |
|
254 |
||
255 |
!GraphicsDevice::GraphicResourceAllocationFailure class methodsFor:'raising'! |
|
256 |
||
257 |
query |
|
258 |
^ self raiseAsQuery |
|
259 |
! ! |
|
260 |
||
1282 | 261 |
!GraphicsDevice class methodsFor:'documentation'! |
262 |
||
263 |
version |
|
7357 | 264 |
^ '$Header$' |
5561 | 265 |
! |
266 |
||
267 |
version_CVS |
|
7357 | 268 |
^ '$Header$' |
1282 | 269 |
! ! |
6220 | 270 |