8772
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
8771
|
3 |
"{ Package: 'stx:libview' }"
|
|
4 |
|
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
|
7 |
DeviceWorkstation subclass:#ElectronWorkstation
|
8775
|
8 |
instanceVariableNames:'bridge eventQueue'
|
|
9 |
classVariableNames:'ExposureMask StructureNotifyMask KeyPressMask KeyReleaseMask
|
|
10 |
PointerMotionMask EnterWindowMask LeaveWindowMask ButtonPressMask
|
|
11 |
ButtonMotionMask ButtonReleaseMask PropertyChangeMask'
|
|
12 |
poolDictionaries:''
|
|
13 |
category:'Interface-Graphics'
|
|
14 |
!
|
|
15 |
|
|
16 |
DeviceGraphicsContext subclass:#ElectronGraphicsContext
|
|
17 |
instanceVariableNames:''
|
8771
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
8775
|
20 |
privateIn:ElectronWorkstation
|
8771
|
21 |
!
|
|
22 |
|
|
23 |
!ElectronWorkstation class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
documentation
|
|
26 |
"
|
8793
|
27 |
experimental work in progress: a Display which draws in an electron application.
|
8804
|
28 |
"
|
|
29 |
!
|
8793
|
30 |
|
8827
|
31 |
example1
|
|
32 |
|v dpy|
|
8804
|
33 |
|
8827
|
34 |
Smalltalk at:#Display2 put:(dpy := ElectronWorkstation newFor:'localhost:8888').
|
|
35 |
v := (TopView onDevice:dpy)
|
|
36 |
label:'Hello';
|
|
37 |
open.
|
|
38 |
v waitUntilVisible.
|
|
39 |
v close.
|
|
40 |
dpy close.
|
8771
|
41 |
! !
|
|
42 |
|
8775
|
43 |
!ElectronWorkstation class methodsFor:'class initialization'!
|
|
44 |
|
|
45 |
initialize
|
|
46 |
ExposureMask := 1 bitShift:0.
|
|
47 |
StructureNotifyMask := 1 bitShift:1.
|
|
48 |
KeyPressMask := 1 bitShift:2.
|
|
49 |
KeyReleaseMask := 1 bitShift:3.
|
|
50 |
PointerMotionMask := 1 bitShift:4.
|
|
51 |
EnterWindowMask := 1 bitShift:5.
|
|
52 |
LeaveWindowMask := 1 bitShift:6.
|
|
53 |
ButtonPressMask := 1 bitShift:7.
|
|
54 |
ButtonMotionMask := 1 bitShift:8.
|
|
55 |
ButtonReleaseMask := 1 bitShift:9.
|
|
56 |
PropertyChangeMask := 1 bitShift:10.
|
|
57 |
! !
|
|
58 |
|
8828
|
59 |
!ElectronWorkstation class methodsFor:'logging'!
|
|
60 |
|
|
61 |
logFacility
|
|
62 |
"the 'log facility';
|
|
63 |
this is used by the Logger both as a prefix to the log message,
|
|
64 |
and maybe (later) used to filter and/or control per-facility log thresholds."
|
|
65 |
|
|
66 |
^ self nameWithoutPrefix
|
|
67 |
! !
|
|
68 |
|
8771
|
69 |
!ElectronWorkstation methodsFor:'accessing & queries'!
|
|
70 |
|
8775
|
71 |
defaultEventMask
|
|
72 |
"return a mask to enable some events by default."
|
|
73 |
|
|
74 |
^ ExposureMask | StructureNotifyMask |
|
|
75 |
KeyPressMask | KeyReleaseMask |
|
|
76 |
PointerMotionMask |
|
|
77 |
EnterWindowMask | LeaveWindowMask |
|
|
78 |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask |
|
|
79 |
PropertyChangeMask
|
|
80 |
|
|
81 |
!
|
|
82 |
|
8771
|
83 |
isOpen
|
|
84 |
"return true, if there is a valid connection to the display"
|
|
85 |
|
|
86 |
^ bridge notNil
|
|
87 |
! !
|
|
88 |
|
8775
|
89 |
!ElectronWorkstation methodsFor:'event handling'!
|
|
90 |
|
|
91 |
eventPending
|
|
92 |
^ eventQueue notNil and:[eventQueue notEmpty]
|
|
93 |
|
|
94 |
! !
|
|
95 |
|
|
96 |
!ElectronWorkstation methodsFor:'font stuff'!
|
|
97 |
|
|
98 |
ascentOf:aFontId
|
|
99 |
"/ the font name is its ID
|
8802
|
100 |
Logger info:'unimplemented: ascentOf'.
|
8775
|
101 |
^ 17
|
|
102 |
!
|
|
103 |
|
|
104 |
descentOf:aFontId
|
|
105 |
"/ the font name is its ID
|
8802
|
106 |
Logger info:'unimplemented: descentOf'.
|
8775
|
107 |
^ 17
|
|
108 |
!
|
|
109 |
|
|
110 |
getFontWithFamily:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnit encoding:encodingSym
|
|
111 |
"try to get the specified font, return id.
|
|
112 |
If not available, try next smaller font.
|
|
113 |
If no font fits, return nil"
|
|
114 |
|
|
115 |
"/ return the font name as ID
|
|
116 |
^ '%1-%2-%3-%4-%5-%6'
|
|
117 |
bindWith:familyString
|
|
118 |
with:faceString
|
|
119 |
with:styleString
|
|
120 |
with:sizeArg
|
|
121 |
with:sizeUnit
|
|
122 |
with:encodingSym
|
|
123 |
!
|
|
124 |
|
|
125 |
maxAscentOf:aFontId
|
|
126 |
"/ the font name is its ID
|
8802
|
127 |
Logger info:'unimplemented: maxAscentOf'.
|
8775
|
128 |
^ 17
|
|
129 |
!
|
|
130 |
|
|
131 |
maxDescentOf:aFontId
|
|
132 |
"/ the font name is its ID
|
8802
|
133 |
Logger info:'unimplemented: maxDescentOf'.
|
8775
|
134 |
^ 17
|
|
135 |
!
|
|
136 |
|
|
137 |
maxWidthOfFont:aFontId
|
|
138 |
"/ the font name is its ID
|
8802
|
139 |
Logger info:'unimplemented: maxWidthOfFont'.
|
8775
|
140 |
^ 20
|
|
141 |
!
|
|
142 |
|
|
143 |
minWidthOfFont:aFontId
|
|
144 |
"/ the font name is its ID
|
8802
|
145 |
Logger info:'unimplemented: minWidthOfFont'.
|
8775
|
146 |
^ 20
|
|
147 |
!
|
|
148 |
|
|
149 |
widthOf:aString from:index1 to:index2 inFont:aFontId
|
|
150 |
"/ the font name is its ID
|
8802
|
151 |
Logger info:'unimplemented: widthOf'.
|
8775
|
152 |
^ (index2-index1+1) * 20
|
|
153 |
! !
|
|
154 |
|
8771
|
155 |
!ElectronWorkstation methodsFor:'initialization & release'!
|
|
156 |
|
|
157 |
closeConnection
|
|
158 |
"close down connection to Display - usually never done"
|
|
159 |
|
|
160 |
|b|
|
|
161 |
|
|
162 |
(b := bridge) notNil ifTrue:[
|
|
163 |
bridge := nil.
|
|
164 |
b close
|
|
165 |
].
|
|
166 |
|
|
167 |
"Created: 13.1.1997 / 22:10:07 / cg"
|
|
168 |
!
|
|
169 |
|
|
170 |
initializeFor:aHostAndPortStringOrNil
|
8788
|
171 |
|nodeBridge _ElectronBridge|
|
|
172 |
|
|
173 |
nodeBridge := Smalltalk requirePackage:'exept:bridgeFramework/nodeJSBridge'.
|
|
174 |
_ElectronBridge := nodeBridge classNamed:'NodeJSBridge::ElectronBridge'.
|
|
175 |
bridge := _ElectronBridge newBridgeForHostAndPort:aHostAndPortStringOrNil.
|
8790
|
176 |
bridge startBridgeIn:'.' debug:true.
|
8827
|
177 |
bridge connectWithTimeoutMS:5000.
|
8771
|
178 |
|
8775
|
179 |
self initializeScreenProperties.
|
|
180 |
self initializeDefaultValues.
|
|
181 |
self initializeKeyboardMap.
|
|
182 |
self initializeDeviceSignals.
|
|
183 |
self initializeDeviceResourceTables.
|
|
184 |
|
|
185 |
Screen default isNil ifTrue:[
|
|
186 |
"not initialized yet?"
|
|
187 |
self initializeViewStyle.
|
|
188 |
].
|
|
189 |
|
8771
|
190 |
"
|
|
191 |
ElectronWorkstation newFor:'localhost:8098'
|
|
192 |
"
|
8775
|
193 |
!
|
|
194 |
|
|
195 |
initializeScreenProperties
|
|
196 |
super initializeScreenProperties.
|
|
197 |
|
|
198 |
monitorType := #unknown.
|
|
199 |
visualType := #TrueColor.
|
|
200 |
depth := 24.
|
|
201 |
redShift := 16.
|
|
202 |
greenShift := 8.
|
|
203 |
blueShift := 0.
|
|
204 |
|
|
205 |
Display notNil ifTrue:[
|
|
206 |
width := Display width.
|
|
207 |
height := Display height.
|
|
208 |
] ifFalse:[
|
|
209 |
width := 1280.
|
|
210 |
height := 1024.
|
|
211 |
].
|
|
212 |
! !
|
|
213 |
|
8802
|
214 |
!ElectronWorkstation methodsFor:'keyboard stuff'!
|
|
215 |
|
|
216 |
ungrabKeyboard
|
|
217 |
Logger info:'unimplemented: ungrabKeyboard'.
|
|
218 |
! !
|
|
219 |
|
8775
|
220 |
!ElectronWorkstation methodsFor:'pointer stuff'!
|
|
221 |
|
|
222 |
pointerPosition
|
8802
|
223 |
Logger info:'unimplemented: pointerPosition'.
|
8775
|
224 |
^ 0@0
|
8802
|
225 |
!
|
|
226 |
|
|
227 |
ungrabPointer
|
|
228 |
Logger info:'unimplemented: ungrabPointer'.
|
8775
|
229 |
! !
|
|
230 |
|
8777
|
231 |
!ElectronWorkstation methodsFor:'window stuff'!
|
|
232 |
|
|
233 |
createWindowFor:aView type:typeSymbol origin:org extent:ext
|
|
234 |
minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv
|
|
235 |
style:styleSymbol inputOnly:inp
|
|
236 |
label:label owner:owner
|
|
237 |
icon:icn iconMask:icnM iconView:icnV
|
|
238 |
|
8802
|
239 |
Logger info:'unimplemented: createWindowFor:'.
|
8804
|
240 |
^ ExternalAddress newAddress:1234 "/ dummy handle (windowID)
|
8777
|
241 |
!
|
|
242 |
|
|
243 |
destroyView:aView withId:aWindowId
|
|
244 |
|
8802
|
245 |
Logger info:'unimplemented: destroyView:'.
|
8777
|
246 |
!
|
|
247 |
|
|
248 |
mapWindow:aWindowId
|
|
249 |
"map a window"
|
|
250 |
|
8802
|
251 |
Logger info:'unimplemented: mapWindow:'.
|
8777
|
252 |
!
|
|
253 |
|
|
254 |
setWindowBackground:aColorIndex in:aWindowId
|
|
255 |
"set a windows background color"
|
|
256 |
|
8802
|
257 |
Logger info:'unimplemented: setWindowBackground:'.
|
8777
|
258 |
!
|
|
259 |
|
|
260 |
setWindowName:aString in:aWindowId
|
|
261 |
"define a windows name (i.e. windowTitle)"
|
|
262 |
|
8802
|
263 |
Logger info:'unimplemented: setWindowName:'.
|
8777
|
264 |
!
|
|
265 |
|
|
266 |
unmapWindow:aWindowId
|
|
267 |
"unmap a window"
|
|
268 |
|
8802
|
269 |
Logger info:'unimplemented: unmapWindow:'.
|
8777
|
270 |
! !
|
|
271 |
|
8775
|
272 |
!ElectronWorkstation::ElectronGraphicsContext class methodsFor:'documentation'!
|
|
273 |
|
|
274 |
documentation
|
|
275 |
"
|
|
276 |
documentation to be added.
|
|
277 |
|
|
278 |
class:
|
|
279 |
<a short class summary here, describing what instances represent>
|
|
280 |
|
|
281 |
responsibilities:
|
|
282 |
<describing what my main role is>
|
|
283 |
|
|
284 |
collaborators:
|
|
285 |
<describing with whom and how I talk to>
|
|
286 |
|
|
287 |
API:
|
|
288 |
<public api and main messages>
|
|
289 |
|
|
290 |
example:
|
|
291 |
<a one-line examples on how to use - can also be in a separate example method>
|
|
292 |
|
|
293 |
implementation:
|
|
294 |
<implementation points>
|
|
295 |
|
|
296 |
[author:]
|
|
297 |
exept MBP
|
|
298 |
|
|
299 |
[instance variables:]
|
|
300 |
|
|
301 |
[class variables:]
|
|
302 |
|
|
303 |
[see also:]
|
|
304 |
|
|
305 |
"
|
8771
|
306 |
! !
|
|
307 |
|
|
308 |
!ElectronWorkstation class methodsFor:'documentation'!
|
|
309 |
|
|
310 |
version_CVS
|
|
311 |
^ '$Header$'
|
|
312 |
! !
|
|
313 |
|
8775
|
314 |
|
|
315 |
ElectronWorkstation initialize!
|