DeviceWorkstation.st
changeset 1580 9a28ea48ec73
parent 1578 01db7f44cbbd
child 1582 ec428aba3f9c
equal deleted inserted replaced
1579:692c2f62d94e 1580:9a28ea48ec73
    22 		altModifiers metaModifiers ctrlModifiers shiftModifiers
    22 		altModifiers metaModifiers ctrlModifiers shiftModifiers
    23 		supportsDeepIcons preferredIconSize ditherColors fixColors
    23 		supportsDeepIcons preferredIconSize ditherColors fixColors
    24 		numFixRed numFixGreen numFixBlue copyBuffer lastCopyBuffer
    24 		numFixRed numFixGreen numFixBlue copyBuffer lastCopyBuffer
    25 		blackColor whiteColor'
    25 		blackColor whiteColor'
    26 	classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal
    26 	classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal
    27 		DeviceIOErrorSignal ErrorPrinting DefaultScreen AllScreens ExitOnLastClose
    27 		DeviceIOErrorSignal ErrorPrinting DefaultScreen AllScreens
    28 		CurrentScreenQuerySignal LastActiveScreen LastActiveProcess'
    28 		ExitOnLastClose CurrentScreenQuerySignal LastActiveScreen
       
    29 		LastActiveProcess'
    29 	poolDictionaries:''
    30 	poolDictionaries:''
    30 	category:'Interface-Graphics'
    31 	category:'Interface-Graphics'
    31 !
    32 !
    32 
    33 
    33 !DeviceWorkstation class methodsFor:'documentation'!
    34 !DeviceWorkstation class methodsFor:'documentation'!
   180 
   181 
   181     One particular device instance is bound to the global variable Display:
   182     One particular device instance is bound to the global variable Display:
   182     this is the default graphics display, on which new views are created
   183     this is the default graphics display, on which new views are created
   183     (however, provisions exist for multi-display operation)
   184     (however, provisions exist for multi-display operation)
   184 
   185 
   185     Currently, there is are only two concrete display classes (released to the public):
   186     Currently, there is are twoconcrete display classes (released to the public):
   186 
   187 
   187 	XWorkstation    - a plain X window interface
   188         XWorkstation    - a plain X window interface
   188 
   189 
   189 	GLXWorkstation  - an X window interface with a GL(tm) (3D graphic library) 
   190         GLXWorkstation  - an X window interface with a GL(tm) (3D graphic library) 
   190 			  extension; either simulated (VGL) or a real GL 
   191                           extension; either simulated (VGL) or a real GL 
   191 			  (real GL is only available on SGI machines)
   192                           (real GL is only available on SGI machines)
   192 
   193 
   193     the following are coming soon:
   194     the following are coming soon:
   194 
   195 
   195 	OpenGLWorkstation   
   196         OpenGLWorkstation   
   196 			- an X window interface with a openGL(tm) (3D graphic library) 
   197                         - an X window interface with a openGL(tm) (3D graphic library) 
   197 			  extension; either simulated (MESA) or a real openGL 
   198                           extension; either simulated (MESA) or a real openGL 
   198 			  (real openGL is only available on SGI/NT machines)
   199                           (real openGL is only available on SGI/NT machines)
   199 
   200 
   200 	WinWorkstation  - what will that be ?
   201         WinWorkstation  - what will that be ?
   201 
   202 
   202     An experimental version for a NeXTStep interface exists, but is currently
   203     An experimental version for a NeXTStep interface exists, but is currently
   203     no longer maintained and not released.
   204     no longer maintained and not released.
   204     Also, interfaces for other graphic systems (i.e. OS/2) are
       
   205     planned for and will be available (hopefully) in late 96.
       
   206 
   205 
   207     DeviceWorkstation itself is an abstract class; the methods as defined
   206     DeviceWorkstation itself is an abstract class; the methods as defined
   208     here perform things which are common to all graphic devices or block
   207     here perform things which are common to all graphic devices or block
   209     methods and raise a subclassResponsibilty error condition.
   208     methods and raise a subclassResponsibilty error condition.
   210     To create a new graphic interface, at least the subclassResponsibilty-methods
   209     To create a new graphic interface, at least the subclassResponsibility-methods
   211     have to be reimplemented in a concrete subclass.
   210     have to be reimplemented in a concrete subclass.
   212 
   211 
   213     ST/X is designed to allow the use of multiple workstation devices in parallel, if
   212     ST/X is designed to allow the use of multiple workstation devices in parallel, 
   214     the underlying window system supports this.
   213     if the underlying window system supports this.
   215     For example, in X, it is possible to create another instance of XWorkstation, 
   214     For example, in X, it is possible to create another instance of XWorkstation, 
   216     start a dispatch process for it, and to create and open views on this display. 
   215     start a dispatch process for it, and to create and open views on this display. 
   217     This does not work with other devices (i.e. Windows).
   216     Multiple display operation does not work with other devices (i.e. Windows).
   218 
   217 
   219     If you want to experiment with multi-display applications,
   218     If you want to experiment with multi-display applications,
   220     you have to:
   219     you have to:
   221 
   220 
   222 	- create a new instance of XWorkstation:
   221     - create a new instance of XWorkstation:
   223 
   222 
   224 	    Smalltalk at:#Display2 put:(XWorkstation new).
   223         Smalltalk at:#Display2 put:(XWorkstation new).
   225 	  or:
   224       or:
   226 	    Smalltalk at:#Display2 put:(GLXWorkstation new).
   225         Smalltalk at:#Display2 put:(GLXWorkstation new).
   227 
   226 
   228 
   227 
   229 	- have it connect to the display (i.e. the xServer):
   228     - have it connect to the display (i.e. the xServer):
   230 	  (replace 'localhost' below with the name of your display)
   229       (replace 'localhost' below with the name of your display)
   231 
   230 
   232 	    Display2 := Display2 initializeFor:'localhost:0.0'
   231         Display2 := Display2 initializeFor:'localhost:0.0'
   233 
   232 
   234 	  returns nil, if connection is refused 
   233       returns nil, if connection is refused 
   235 	  - leaving you with Display2==nil in this case.
   234       - leaving you with Display2==nil in this case.
   236 
   235 
   237 
   236 
   238 	- start an event dispatcher process for it:
   237     - start an event dispatcher process for it:
   239 	  (this is now no longer needed - the first opened view will do it for you)
   238       (this is now no longer needed - the first opened view will do it for you)
   240 
   239 
   241 	    Display2 startDispatch
   240         Display2 startDispatch
   242 
   241 
   243 
   242 
   244 	- optionally set its keyboard map
   243     - optionally set its keyboard map
   245 	  (since this is usually done for Display in the startup-file,
   244       (since this is usually done for Display in the startup-file,
   246 	   the new display does not have all your added key bindings)
   245        the new display does not have all your added key bindings)
   247 
   246 
   248 	    Display2 keyboardMap:(Display keyboardMap)
   247         Display2 keyboardMap:(Display keyboardMap)
   249 
   248 
   250 
   249 
   251 	- create a view for it:
   250     - create a view for it:
   252 
   251 
   253 	    (FileBrowser onDevice:Display2) open
   252         (FileBrowser onDevice:Display2) open
   254 
   253 
   255 	    (Workspace onDevice:Display2) open
   254         (Workspace onDevice:Display2) open
   256 
   255 
   257 	    (Launcher onDevice:Display2) open
   256         (Launcher onDevice:Display2) open
   258 		does not work with Launcher, since its an ApplicationModel (not a view)
   257             does not work with Launcher, since its an ApplicationModel (not a view)
   259 		use:
   258             use:
   260 		    Launcher openOnDevice:Display2
   259                 Launcher openOnDevice:Display2
   261 		instead.
   260             instead.
   262 
   261 
   263     However, as mentioned above, there may be a few places, where the default
   262     However, as mentioned above, there may be a few places, where the default
   264     display 'Display' is still hard-coded - especially, in contributed and
   263     display 'Display' is still hard-coded - especially, in contributed and
   265     Public domain code, you may find those.
   264     Public domain code, you may find those.
   266 
   265 
   267     Beside this (little bug ;-), remote display operation works pretty well. 
   266     Beside this (little bug ;-), remote display operation works pretty well. 
   268     If you write your application to work around those, multi-display applications are
   267     If you write your application to work around those, multi-display applications are
   269     possible in the current release.
   268     possible in the current release (and actually being used in a concrete application,
       
   269     where up to 6 x-terminals are connected to a single linux PC).
   270 
   270 
   271     To make your application ready for multi-display operation, replace all
   271     To make your application ready for multi-display operation, replace all
   272     references to 'Display' by: 'Screen current', which evaluates to the currently
   272     references to 'Display' by: 'Screen current', which evaluates to the currently
   273     active display. I.e. each view gets its actual display via this expression.
   273     active display. I.e. each view gets its actual display via this expression.
   274     Since ST/X views already use this, new views opened by remote views should
   274     Since ST/X views already use this, new views opened by remote views should
   276 
   276 
   277     There is no easy solution for things like Notifiers, WarnBoxes or
   277     There is no easy solution for things like Notifiers, WarnBoxes or
   278     Debuggers when opened from some background or non-view process.
   278     Debuggers when opened from some background or non-view process.
   279     These will come up one the default Display, as returned by 'Screen default'.
   279     These will come up one the default Display, as returned by 'Screen default'.
   280 
   280 
       
   281     Finally, your application should care for I/O errors (i.e. lost connection when
       
   282     a remote display is switched off).
       
   283     The framework provides per-display signals, which are raised in the corresponding
       
   284     event dispatchers context.
       
   285     For a save environment, you should add static exception handler blocks on those 
       
   286     signals; i.e. the setup for remote displays should look somewhat like:
       
   287         |newDpy|
       
   288 
       
   289         newDpy := GLXWorkstation new.
       
   290         newDpy := newDpy initializeFor:'localhost:0.0'.
       
   291         newDpy isNil ifTrue:[
       
   292             self warn:'cannot connect ...'.
       
   293         ] ifFalse:[
       
   294             newDpy deviceIOErrorSignal handlerBlock:[:ex |
       
   295                 Transcript beep.
       
   296                 Transcript showCR:'Display (' , newDpy displayName , '): connection broken.'.
       
   297                 AbortSignal raise.
       
   298             ].
       
   299             newDpy startDispatch.
       
   300             Launcher openOnDevice:newDpy.
       
   301         ].
       
   302 
   281     There may still some problems to be expected,
   303     There may still some problems to be expected,
   282     if the screens have different display capabilities (b&w vs. greyscale vs.
   304     if the screens have different display capabilities (b&w vs. greyscale vs.
   283     color display). The current styleSheet approach keeps default values
   305     color display). The current styleSheet approach keeps default values
   284     only once (it should do so per display ...) For now, expect ugly looking
   306     only once (it should do so per display ...) 
   285     views in this case - or set your styleSheet for the smallest common 
   307     For now, expect ugly looking views in this case - or set your styleSheet 
   286     capabilities (i.e. for b&w).
   308     for the smallest common capabilities (i.e. for b&w).
       
   309     This may be fixed in a future version ...
       
   310 
   287 "
   311 "
   288 ! !
   312 ! !
   289 
   313 
   290 !DeviceWorkstation class methodsFor:'initialization'!
   314 !DeviceWorkstation class methodsFor:'initialization'!
   291 
   315 
   341     "return the signal used for device I/O error reporting.
   365     "return the signal used for device I/O error reporting.
   342      In multi-display configurations, this is the parent of
   366      In multi-display configurations, this is the parent of
   343      all per-instance deviceIOErrorSignals."
   367      all per-instance deviceIOErrorSignals."
   344 
   368 
   345     ^ DeviceIOErrorSignal
   369     ^ DeviceIOErrorSignal
   346 ! !
       
   347 
       
   348 !DeviceWorkstation methodsFor:'Signal constants'!
       
   349 
       
   350 deviceErrorSignal
       
   351     "return the per-device signal, which is used for error reporting.
       
   352      The default here is the global DeviceErrorSignal (which is the
       
   353      parent of the per-instance signals)."
       
   354 
       
   355     ^ self class deviceErrorSignal
       
   356 !
       
   357 
       
   358 deviceIOErrorSignal
       
   359     "return the signal used for device I/O error reporting.
       
   360      The default here is the global DeviceIOErrorSignal (which is the
       
   361      parent of the per-instance signals)."
       
   362 
       
   363     ^ self class deviceIOErrorSignal
       
   364 ! !
   370 ! !
   365 
   371 
   366 !DeviceWorkstation class methodsFor:'accessing'!
   372 !DeviceWorkstation class methodsFor:'accessing'!
   367 
   373 
   368 buttonTranslation:anArray
   374 buttonTranslation:anArray
   751      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) speed:2000
   757      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) speed:2000
   752     "
   758     "
   753 
   759 
   754     "Created: 27.1.1997 / 18:19:35 / cg"
   760     "Created: 27.1.1997 / 18:19:35 / cg"
   755     "Modified: 27.1.1997 / 18:24:58 / cg"
   761     "Modified: 27.1.1997 / 18:24:58 / cg"
       
   762 ! !
       
   763 
       
   764 !DeviceWorkstation methodsFor:'Signal constants'!
       
   765 
       
   766 deviceErrorSignal
       
   767     "return the per-device signal, which is used for error reporting.
       
   768      The default here is the global DeviceErrorSignal (which is the
       
   769      parent of the per-instance signals)."
       
   770 
       
   771     ^ self class deviceErrorSignal
       
   772 !
       
   773 
       
   774 deviceIOErrorSignal
       
   775     "return the signal used for device I/O error reporting.
       
   776      The default here is the global DeviceIOErrorSignal (which is the
       
   777      parent of the per-instance signals)."
       
   778 
       
   779     ^ self class deviceIOErrorSignal
   756 ! !
   780 ! !
   757 
   781 
   758 !DeviceWorkstation methodsFor:'accessing & queries'!
   782 !DeviceWorkstation methodsFor:'accessing & queries'!
   759 
   783 
   760 buttonMotionMask:aMask includesButton:aButton
   784 buttonMotionMask:aMask includesButton:aButton
  5362 ! !
  5386 ! !
  5363 
  5387 
  5364 !DeviceWorkstation class methodsFor:'documentation'!
  5388 !DeviceWorkstation class methodsFor:'documentation'!
  5365 
  5389 
  5366 version
  5390 version
  5367     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.204 1997-04-11 09:35:21 cg Exp $'
  5391     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.205 1997-04-11 10:40:02 cg Exp $'
  5368 ! !
  5392 ! !
  5369 DeviceWorkstation initialize!
  5393 DeviceWorkstation initialize!