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