author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 25 Feb 2016 07:35:46 +0000 | |
branch | jv |
changeset 7166 | 1f7489fd814e |
parent 6357 | bc674a4f8cfd |
child 7365 | 05f5fe42c919 |
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 |
||
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
|
14 |
"{ NameSpace: Smalltalk }" |
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
|
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 |
" |
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 |
! |
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 |
|
1282 | 30 |
!GraphicsDevice class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
1283 | 34 |
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger |
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
35 |
All Rights Reserved |
1282 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
||
45 |
! |
|
46 |
||
47 |
documentation |
|
48 |
" |
|
49 |
this abstract class was inserted to provide a home for ST-80 classes |
|
50 |
(previously, DeviceWorkstation was directly under Object). |
|
51 |
||
1283 | 52 |
In ST/X, this is mostly dummy. |
53 |
||
1282 | 54 |
[instance variables:] |
3443 | 55 |
displayId <Handle> the device handle |
56 |
screen any another some device specific id |
|
57 |
eventListeners <Collection> | nil bunch of objects interested in events. |
|
58 |
deviceType <Symbol> some arbitrary symbol, used to choose windowSpecs. |
|
1282 | 59 |
|
60 |
[see also:] |
|
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
61 |
DeviceWorkstation XWorkstation |
1282 | 62 |
|
63 |
[author:] |
|
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
64 |
Claus Gittinger |
1282 | 65 |
" |
66 |
||
67 |
! ! |
|
68 |
||
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
|
69 |
!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
|
70 |
|
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
|
71 |
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
|
72 |
"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
|
73 |
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
|
74 |
^ 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
|
75 |
|
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 |
"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
|
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 |
|
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 |
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
|
80 |
"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
|
81 |
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
|
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 |
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
|
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: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
|
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 |
!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
|
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 |
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 |
"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
|
92 |
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
|
93 |
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
|
94 |
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
|
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 |
^ 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
|
97 |
|
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 |
"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
|
99 |
! |
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 |
|
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: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
|
102 |
"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
|
103 |
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
|
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 := 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
|
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 (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
|
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 |
|
3445 | 110 |
!GraphicsDevice methodsFor:'accessing & queries'! |
3198 | 111 |
|
112 |
addEventListener:aListener |
|
113 |
"add a local eventListener (with new protocol - #processEvent:) |
|
114 |
This one gets a chance to intercept all events for this device" |
|
115 |
||
116 |
eventListeners isNil ifTrue:[ |
|
3488 | 117 |
eventListeners := OrderedCollection new:2 |
3198 | 118 |
]. |
3488 | 119 |
(eventListeners includesIdentical:aListener) ifFalse:[ |
120 |
eventListeners add:aListener |
|
121 |
]. |
|
3198 | 122 |
! |
123 |
||
3445 | 124 |
bePDA |
125 |
self deviceType:#pda |
|
3443 | 126 |
! |
3198 | 127 |
|
3443 | 128 |
deviceType |
129 |
^ deviceType |
|
130 |
! |
|
3198 | 131 |
|
3443 | 132 |
deviceType:aSymbol |
133 |
deviceType := aSymbol |
|
3445 | 134 |
! |
135 |
||
136 |
isPDA |
|
137 |
^ self deviceType == #pda |
|
138 |
! |
|
139 |
||
5561 | 140 |
isWebServiceDevice |
141 |
"I am not a WebService pseude-device" |
|
142 |
||
143 |
^ false |
|
144 |
! |
|
145 |
||
3445 | 146 |
removeEventListener:aListener |
147 |
"remove a local eventListener (with new protocol - #processEvent:)" |
|
148 |
||
149 |
eventListeners notNil ifTrue:[ |
|
150 |
eventListeners removeIdentical:aListener ifAbsent:nil |
|
151 |
]. |
|
3198 | 152 |
! ! |
153 |
||
6220 | 154 |
!GraphicsDevice methodsFor:'creating graphics contexts'! |
155 |
||
156 |
newGraphicsContextFor:aGraphicsMedium |
|
157 |
"create a new graphics context. |
|
158 |
The defaults is to use the inherited graphics context. |
|
159 |
Subclasses may redefine this to use their own graphics context" |
|
160 |
||
6357 | 161 |
|gc| |
162 |
||
163 |
GraphicsMedium superclass == DeviceGraphicsContext ifTrue:[ |
|
164 |
"this is for transition to delegatest GC" |
|
165 |
^ aGraphicsMedium. |
|
166 |
]. |
|
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
|
167 |
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
|
168 |
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
|
169 |
]. |
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
|
170 |
gc := graphicsContextClass onDevice:self. |
6357 | 171 |
gc font:aGraphicsMedium class defaultFont. |
172 |
^ 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
|
173 |
|
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 |
"Modified: / 25-02-2016 / 07:32:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6220 | 175 |
! ! |
176 |
||
3198 | 177 |
!GraphicsDevice methodsFor:'event processing'! |
178 |
||
179 |
notifyEventListenersAbout:anEvent |
|
180 |
"notify all eventHandlers about an incoming event. |
|
181 |
If any returns true, it is assumed to be eaten by the handler and not |
|
182 |
enqueued (i.e. not passed to the windowGroup process)" |
|
183 |
||
184 |
|anyListenerReturnedTrue| |
|
185 |
||
186 |
anyListenerReturnedTrue := false. |
|
187 |
||
188 |
"/ local listeners ... |
|
189 |
eventListeners notNil ifTrue:[ |
|
3222
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
190 |
eventListeners do:[:aListener | |
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
191 |
anyListenerReturnedTrue := anyListenerReturnedTrue | |
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
192 |
(aListener processEvent:anEvent) |
0bb571e07c0e
moved screen instance variable
Claus Gittinger <cg@exept.de>
parents:
3198
diff
changeset
|
193 |
] |
3198 | 194 |
]. |
195 |
||
196 |
^ anyListenerReturnedTrue. |
|
197 |
||
198 |
! ! |
|
199 |
||
3577 | 200 |
!GraphicsDevice methodsFor:'misc'! |
201 |
||
202 |
roundTripTime |
|
203 |
"answer the round trip time in milliseconds. |
|
5561 | 204 |
May be used to detect slow device connections. |
3577 | 205 |
Subclasses redefine this. Assume a fast Diplay connection |
206 |
and answer 0 here" |
|
207 |
||
208 |
^ 0 |
|
209 |
||
210 |
" |
|
211 |
Screen current roundTripTime |
|
212 |
" |
|
213 |
! ! |
|
214 |
||
1282 | 215 |
!GraphicsDevice class methodsFor:'documentation'! |
216 |
||
217 |
version |
|
6357 | 218 |
^ '$Header: /cvs/stx/stx/libview/GraphicsDevice.st,v 1.14 2014-03-25 09:01:41 stefan Exp $' |
5561 | 219 |
! |
220 |
||
221 |
version_CVS |
|
6357 | 222 |
^ '$Header: /cvs/stx/stx/libview/GraphicsDevice.st,v 1.14 2014-03-25 09:01:41 stefan Exp $' |
1282 | 223 |
! ! |
6220 | 224 |