GraphicsDevice.st
branchjv
changeset 7166 1f7489fd814e
parent 6357 bc674a4f8cfd
child 7365 05f5fe42c919
--- 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'!