GraphicsDevice.st
author Stefan Vogel <sv@exept.de>
Tue, 28 Apr 2020 15:28:14 +0200
changeset 9038 dd177fea6408
parent 8927 970fc2d97125
permissions -rw-r--r--
#REFACTORING by stefan class: Font changed: #setFamily:face:style:size:sizeUnit:encoding:device:

"{ Encoding: utf8 }"

"
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libview' }"

"{ NameSpace: Smalltalk }"

Object subclass:#GraphicsDevice
	instanceVariableNames:'displayId screen eventListeners deviceType'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Graphics'
!

AllocationFailure subclass:#GraphicResourceAllocationFailure
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:GraphicsDevice
!

!GraphicsDevice class methodsFor:'documentation'!

copyright
"
COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

!

documentation
"
    this abstract class was inserted to provide a home for ST-80 classes
    (previously, DeviceWorkstation was directly under Object).

    In ST/X, this is mostly dummy.

    [instance variables:]
      displayId       <Handle>            the device handle
      screen          any                 another some device specific id
      eventListeners  <Collection> | nil  bunch of objects interested in events.
      deviceType      <Symbol>             some arbitrary symbol, used to choose windowSpecs.

    [see also:]
	DeviceWorkstation XWorkstation

    [author:]
	Claus Gittinger
"

! !

!GraphicsDevice methodsFor:'accessing & queries'!

addEventListener:aListener
    "add a local eventListener (with new protocol - #processEvent:)
     This one gets a chance to intercept all events for this device"

    eventListeners isNil ifTrue:[
        eventListeners := OrderedCollection new:2
    ].
    (eventListeners includesIdentical:aListener) ifFalse:[
        eventListeners add:aListener
    ].
!

bePDA
    self deviceType:#pda
!

deviceType
    ^ deviceType
!

deviceType:aSymbol
    deviceType := aSymbol
!

isPDA
    ^ self deviceType == #pda
!

isWebServiceDevice
    "I am not a WebService pseudo-device"

    ^ false

    "Modified (comment): / 27-05-2019 / 20:05:12 / Claus Gittinger"
!

literalArrayEncoding
    self shouldNeverBeSent

    "Created: / 28-10-2018 / 11:34:08 / Claus Gittinger"
!

removeEventListener:aListener
    "remove a local eventListener (with new protocol - #processEvent:)"

    eventListeners notNil ifTrue:[
	eventListeners removeIdentical:aListener ifAbsent:nil
    ].
!

supportsAlphaChannel
    "return true, if this device supports alpha information.
     Currently none does"    

    ^ false

    "
     Display supportsAlpha
    "

    "Created: / 11-04-2017 / 01:41:52 / cg"
    "Modified (comment): / 12-04-2017 / 09:57:43 / cg"
!

supportsJPGImages
    "return true, if this device directly supports jpg images.
     Currently none does (except browser windows)"    

    ^ false

    "
     Display supportsJPGImages
    "
!

supportsNativeImages
    "return true, if this device directly supports images (png, jpg, tiff, etc.).
     If true is returned, the concrete image format to use must be negotiated further.
     Currently none does (except browser windows and electron)"    

    ^ false

    "
     Display supportsPNGImages
    "
!

supportsPNGImages
    "return true, if this device directly supports png images.
     Currently none does (except browser windows)"    

    ^ false

    "
     Display supportsPNGImages
    "
!

supportsTIFFImages
    "return true, if this device directly supports tiff images.
     Currently none does (except browser windows)"    

    ^ false

    "
     Display supportsTIFFImages
    "
! !

!GraphicsDevice methodsFor:'creating graphics contexts'!

newGraphicsContextFor:aGraphicsMedium
    "create a new graphics context.
     The default is to use the inherited graphics context.
     Subclasses may redefine this to use their own graphics context"

    ^ DeviceGraphicsContext onDevice:self.
! !

!GraphicsDevice methodsFor:'event processing'!

notifyEventListenersAbout:anEvent
    "notify all eventHandlers about an incoming event.
     If any returns true, it is assumed to be eaten by the handler and not
     enqueued (i.e. not passed to the windowGroup process)"

    |anyListenerReturnedTrue|

    anyListenerReturnedTrue := false.

    "/ local listeners ...
    eventListeners notNil ifTrue:[
        eventListeners do:[:aListener |
            "/ notice: evaluating or here; all listeners get a chance
            anyListenerReturnedTrue := anyListenerReturnedTrue |
                                       (aListener processEvent:anEvent)
        ]
    ].
    "/ anyListenerReturnedTrue ifTrue:[
    "/     'eaten by device listener' infoPrintCR.
    "/ ].
    ^ anyListenerReturnedTrue.
! !

!GraphicsDevice methodsFor:'misc'!

roundTripTime
    "answer the round trip time in milliseconds.
     May be used to detect slow device connections.
     Subclasses redefine this. Assume a fast Diplay connection
     and answer 0 here"

    ^ 0

    "
     Screen current roundTripTime
    "
! !

!GraphicsDevice::GraphicResourceAllocationFailure class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2016 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    raised when allocation of a graphics resource (pixmap, bitmap, cursor, font, etc.)
    fails.
"
! !

!GraphicsDevice::GraphicResourceAllocationFailure class methodsFor:'queries'!

defaultAnswer
    ^ nil
!

isQuerySignal
    ^ true
! !

!GraphicsDevice::GraphicResourceAllocationFailure class methodsFor:'raising'!

query
    ^ self raiseAsQuery
! !

!GraphicsDevice class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !