Allow to configure a graphics context class to use with given graphics device type
...or with given device instance. This is usually not needed as one may stick
with defaults, but some packages - most notably Cairo - may use this to hook in
its own implementation and thus use altertnative rendering.
--- a/GraphicsDevice.st Thu Feb 25 10:14:09 2016 +0000
+++ b/GraphicsDevice.st Thu Feb 25 07:35:46 2016 +0000
@@ -11,13 +11,22 @@
"
"{ Package: 'stx:libview' }"
+"{ NameSpace: Smalltalk }"
+
Object subclass:#GraphicsDevice
- instanceVariableNames:'displayId screen eventListeners deviceType'
+ instanceVariableNames:'displayId screen eventListeners deviceType graphicsContextClass'
classVariableNames:''
poolDictionaries:''
category:'Interface-Graphics'
!
+GraphicsDevice class instanceVariableNames:'graphicsContextClass'
+
+"
+ No other class instance variables are inherited by this class.
+"
+!
+
!GraphicsDevice class methodsFor:'documentation'!
copyright
@@ -57,6 +66,47 @@
! !
+!GraphicsDevice class methodsFor:'accessing'!
+
+graphicsContextClass
+ "Return a graphics context class to use for this graphics device type.
+ Default is to use DeviceGraphicsContext"
+ ^ graphicsContextClass ? DeviceGraphicsContext
+
+ "Modified (comment): / 25-02-2016 / 07:30:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+graphicsContextClass:aClass
+ "Set a graphics context class to use for this graphics device type.
+ Usually there's no need set this, just stich with defaults."
+
+ graphicsContextClass := aClass.
+
+ "Modified (comment): / 25-02-2016 / 07:30:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!GraphicsDevice methodsFor:'accessing'!
+
+graphicsContextClass
+ "Return a graphics context class to use for this device.
+ Default is to use DeviceGraphicsContext"
+ graphicsContextClass isNil ifTrue:[
+ graphicsContextClass := self class graphicsContextClass.
+ ].
+ ^ graphicsContextClass
+
+ "Modified: / 25-02-2016 / 07:31:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+graphicsContextClass:aClass
+ "Set a graphics context class to use for this device.
+ Usually there's no need set this, just stich with defaults."
+
+ graphicsContextClass := aClass.
+
+ "Modified (comment): / 25-02-2016 / 07:26:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!GraphicsDevice methodsFor:'accessing & queries'!
addEventListener:aListener
@@ -114,10 +164,14 @@
"this is for transition to delegatest GC"
^ aGraphicsMedium.
].
-
- gc := DeviceGraphicsContext onDevice:self.
+ graphicsContextClass isNil ifTrue:[
+ graphicsContextClass := self class graphicsContextClass.
+ ].
+ gc := graphicsContextClass onDevice:self.
gc font:aGraphicsMedium class defaultFont.
^ gc.
+
+ "Modified: / 25-02-2016 / 07:32:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GraphicsDevice methodsFor:'event processing'!
--- a/XWorkstation.st Thu Feb 25 10:14:09 2016 +0000
+++ b/XWorkstation.st Thu Feb 25 07:35:46 2016 +0000
@@ -29,7 +29,7 @@
selectionFetchers selectionHandlers preWaitAction xlibTimeout
xlibTimeoutForWindowCreation hasConnectionBroken uniqueDeviceID
stxDeviceAtom uuidAtom primaryBuffer windowGroupWindow
- maxOperationsUntilFlush operationsUntilFlush lastError hostname
+ maxOperationsUntilFlush operationsUntilFlush lastError hostname
wmClientLeaderAtom wmClientMachineAtom wmClassName wmClassClass
pid netWmPidAtom'
classVariableNames:'RawKeySymTranslation ConservativeSync MaxStringLength
@@ -738,6 +738,16 @@
"Modified: / 27.4.1999 / 17:21:30 / cg"
! !
+!XWorkstation class methodsFor:'accessing'!
+
+graphicsContextClass
+ "Return a graphics context class to use for this device.
+ Default is to use DeviceGraphicsContext"
+ ^ graphicsContextClass ? XGraphicsContext
+
+ "Created: / 25-02-2016 / 07:26:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!XWorkstation class methodsFor:'accessing-display capabilities'!
hasXftLibrary
@@ -12534,19 +12544,6 @@
self primitiveFailedOrClosedConnection
!
-newGraphicsContextFor:aGraphicsMedium
- "create a new graphics context.
- The defaults is to use the inherited graphics context.
- Subclasses may redefine this to use their own graphics context"
-
-"/ ^ aGraphicsMedium.
- |gc|
-
- gc := XGraphicsContext onDevice:self.
- gc font:aGraphicsMedium class defaultFont.
- ^ gc.
-!
-
parentWindowIdOf:aWindowId
"return a windows parent-window id.
Useful with getGeometryOf:, to compute information about the decoration."
@@ -13893,6 +13890,11 @@
^ '$Header$'
!
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+!
+
version_SVN
^ '$ Id $'
! !