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