#DOCUMENTATION by exept
class: ElectronWorkstation class
comment/format in: #documentation
"{ Encoding: utf8 }"
"{ Package: 'stx:libview' }"
"{ NameSpace: Smalltalk }"
DeviceWorkstation subclass:#ElectronWorkstation
instanceVariableNames:'bridge eventQueue'
classVariableNames:'ExposureMask StructureNotifyMask KeyPressMask KeyReleaseMask
PointerMotionMask EnterWindowMask LeaveWindowMask ButtonPressMask
ButtonMotionMask ButtonReleaseMask PropertyChangeMask'
poolDictionaries:''
category:'Interface-Graphics'
!
DeviceGraphicsContext subclass:#ElectronGraphicsContext
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
privateIn:ElectronWorkstation
!
!ElectronWorkstation class methodsFor:'documentation'!
documentation
"
experimental work in progress: a Display which draws in an electron application.
Smalltalk at:#Display2 put:(ElectronWorkstation newFor:'localhost:8588').
(TopView onDevice:Display2)
label:'Hello';
open
"
! !
!ElectronWorkstation class methodsFor:'class initialization'!
initialize
ExposureMask := 1 bitShift:0.
StructureNotifyMask := 1 bitShift:1.
KeyPressMask := 1 bitShift:2.
KeyReleaseMask := 1 bitShift:3.
PointerMotionMask := 1 bitShift:4.
EnterWindowMask := 1 bitShift:5.
LeaveWindowMask := 1 bitShift:6.
ButtonPressMask := 1 bitShift:7.
ButtonMotionMask := 1 bitShift:8.
ButtonReleaseMask := 1 bitShift:9.
PropertyChangeMask := 1 bitShift:10.
! !
!ElectronWorkstation methodsFor:'accessing & queries'!
defaultEventMask
"return a mask to enable some events by default."
^ ExposureMask | StructureNotifyMask |
KeyPressMask | KeyReleaseMask |
PointerMotionMask |
EnterWindowMask | LeaveWindowMask |
ButtonPressMask | ButtonMotionMask | ButtonReleaseMask |
PropertyChangeMask
!
isOpen
"return true, if there is a valid connection to the display"
^ bridge notNil
! !
!ElectronWorkstation methodsFor:'event handling'!
eventPending
^ eventQueue notNil and:[eventQueue notEmpty]
! !
!ElectronWorkstation methodsFor:'font stuff'!
ascentOf:aFontId
"/ the font name is its ID
^ 17
!
descentOf:aFontId
"/ the font name is its ID
^ 17
!
getFontWithFamily:familyString face:faceString style:styleString size:sizeArg sizeUnit:sizeUnit encoding:encodingSym
"try to get the specified font, return id.
If not available, try next smaller font.
If no font fits, return nil"
"/ return the font name as ID
^ '%1-%2-%3-%4-%5-%6'
bindWith:familyString
with:faceString
with:styleString
with:sizeArg
with:sizeUnit
with:encodingSym
!
maxAscentOf:aFontId
"/ the font name is its ID
^ 17
!
maxDescentOf:aFontId
"/ the font name is its ID
^ 17
!
maxWidthOfFont:aFontId
"/ the font name is its ID
^ 20
!
minWidthOfFont:aFontId
"/ the font name is its ID
^ 20
!
widthOf:aString from:index1 to:index2 inFont:aFontId
"/ the font name is its ID
^ (index2-index1+1) * 20
! !
!ElectronWorkstation methodsFor:'initialization & release'!
closeConnection
"close down connection to Display - usually never done"
|b|
(b := bridge) notNil ifTrue:[
bridge := nil.
b close
].
"Created: 13.1.1997 / 22:10:07 / cg"
!
initializeFor:aHostAndPortStringOrNil
|nodeBridge _ElectronBridge|
nodeBridge := Smalltalk requirePackage:'exept:bridgeFramework/nodeJSBridge'.
_ElectronBridge := nodeBridge classNamed:'NodeJSBridge::ElectronBridge'.
bridge := _ElectronBridge newBridgeForHostAndPort:aHostAndPortStringOrNil.
bridge startBridgeIn:'.' debug:true.
bridge connect.
self initializeScreenProperties.
self initializeDefaultValues.
self initializeKeyboardMap.
self initializeDeviceSignals.
self initializeDeviceResourceTables.
Screen default isNil ifTrue:[
"not initialized yet?"
self initializeViewStyle.
].
"
ElectronWorkstation newFor:'localhost:8098'
"
!
initializeScreenProperties
super initializeScreenProperties.
monitorType := #unknown.
visualType := #TrueColor.
depth := 24.
redShift := 16.
greenShift := 8.
blueShift := 0.
Display notNil ifTrue:[
width := Display width.
height := Display height.
] ifFalse:[
width := 1280.
height := 1024.
].
! !
!ElectronWorkstation methodsFor:'pointer stuff'!
pointerPosition
^ 0@0
! !
!ElectronWorkstation methodsFor:'window stuff'!
createWindowFor:aView type:typeSymbol origin:org extent:ext
minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv
style:styleSymbol inputOnly:inp
label:label owner:owner
icon:icn iconMask:icnM iconView:icnV
^ 1234
!
destroyView:aView withId:aWindowId
self halt.
!
mapWindow:aWindowId
"map a window"
self halt.
!
setWindowBackground:aColorIndex in:aWindowId
"set a windows background color"
self halt.
!
setWindowName:aString in:aWindowId
"define a windows name (i.e. windowTitle)"
self halt.
!
unmapWindow:aWindowId
"unmap a window"
self halt.
! !
!ElectronWorkstation::ElectronGraphicsContext class methodsFor:'documentation'!
documentation
"
documentation to be added.
class:
<a short class summary here, describing what instances represent>
responsibilities:
<describing what my main role is>
collaborators:
<describing with whom and how I talk to>
API:
<public api and main messages>
example:
<a one-line examples on how to use - can also be in a separate example method>
implementation:
<implementation points>
[author:]
exept MBP
[instance variables:]
[class variables:]
[see also:]
"
! !
!ElectronWorkstation class methodsFor:'documentation'!
version_CVS
^ '$Header$'
! !
ElectronWorkstation initialize!