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