ElectronWorkstation.st
changeset 8775 e7b56d14fa77
parent 8772 4bfdf08ef358
child 8777 41f6f70e6919
equal deleted inserted replaced
8774:b7b97afe2599 8775:e7b56d14fa77
     3 "{ Package: 'stx:libview' }"
     3 "{ Package: 'stx:libview' }"
     4 
     4 
     5 "{ NameSpace: Smalltalk }"
     5 "{ NameSpace: Smalltalk }"
     6 
     6 
     7 DeviceWorkstation subclass:#ElectronWorkstation
     7 DeviceWorkstation subclass:#ElectronWorkstation
     8 	instanceVariableNames:'bridge'
     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:''
     9 	classVariableNames:''
    18 	classVariableNames:''
    10 	poolDictionaries:''
    19 	poolDictionaries:''
    11 	category:'Interface-Graphics'
    20 	privateIn:ElectronWorkstation
    12 !
    21 !
    13 
    22 
    14 !ElectronWorkstation class methodsFor:'documentation'!
    23 !ElectronWorkstation class methodsFor:'documentation'!
    15 
    24 
    16 documentation
    25 documentation
    17 "
    26 "
    18     Smalltalk at:#Display2 put:(ElectronWorkstation newFor:nil).
    27     Smalltalk at:#Display2 put:(ElectronWorkstation newFor:'localhost:8588').
    19     (TopView onDevice:Display2) 
    28     (TopView onDevice:Display2) 
    20         label:'Hello';
    29         label:'Hello';
    21         open
    30         open
    22 "
    31 "
    23 ! !
    32 ! !
    24 
    33 
       
    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 
    25 !ElectronWorkstation methodsFor:'accessing & queries'!
    50 !ElectronWorkstation methodsFor:'accessing & queries'!
       
    51 
       
    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 !
    26 
    63 
    27 isOpen
    64 isOpen
    28     "return true, if there is a valid connection to the display"
    65     "return true, if there is a valid connection to the display"
    29 
    66 
    30     ^ bridge notNil
    67     ^ bridge notNil
       
    68 ! !
       
    69 
       
    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
    31 ! !
   127 ! !
    32 
   128 
    33 !ElectronWorkstation methodsFor:'initialization & release'!
   129 !ElectronWorkstation methodsFor:'initialization & release'!
    34 
   130 
    35 closeConnection
   131 closeConnection
    52         command:'node' 
   148         command:'node' 
    53         environment:nil 
   149         environment:nil 
    54         debug:false.
   150         debug:false.
    55     bridge connect.
   151     bridge connect.
    56 
   152 
       
   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 
    57     "
   164     "
    58      ElectronWorkstation newFor:'localhost:8098'
   165      ElectronWorkstation newFor:'localhost:8098'
    59     "
   166     "
       
   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 
       
   194 !ElectronWorkstation::ElectronGraphicsContext class methodsFor:'documentation'!
       
   195 
       
   196 documentation
       
   197 "
       
   198     documentation to be added.
       
   199 
       
   200     class:
       
   201         <a short class summary here, describing what instances represent>
       
   202 
       
   203     responsibilities:    
       
   204         <describing what my main role is>
       
   205 
       
   206     collaborators:    
       
   207         <describing with whom and how I talk to>
       
   208 
       
   209     API:
       
   210         <public api and main messages>
       
   211         
       
   212     example:
       
   213         <a one-line examples on how to use - can also be in a separate example method>
       
   214 
       
   215     implementation:
       
   216         <implementation points>
       
   217 
       
   218     [author:]
       
   219         exept MBP
       
   220 
       
   221     [instance variables:]
       
   222 
       
   223     [class variables:]
       
   224 
       
   225     [see also:]
       
   226 
       
   227 "
    60 ! !
   228 ! !
    61 
   229 
    62 !ElectronWorkstation class methodsFor:'documentation'!
   230 !ElectronWorkstation class methodsFor:'documentation'!
    63 
   231 
    64 version_CVS
   232 version_CVS
    65     ^ '$Header$'
   233     ^ '$Header$'
    66 ! !
   234 ! !
    67 
   235 
       
   236 
       
   237 ElectronWorkstation initialize!