*** empty log message ***
authorfm
Wed, 15 Nov 2006 10:15:41 +0100
changeset 2272 64e4bdfc84b9
parent 2271 8ad7158a757a
child 2273 14e357a2c73f
*** empty log message ***
PrinterContext.st
--- a/PrinterContext.st	Fri Oct 27 17:13:07 2006 +0200
+++ b/PrinterContext.st	Wed Nov 15 10:15:41 2006 +0100
@@ -12,7 +12,7 @@
 "{ Package: 'stx:libview2' }"
 
 GraphicsMedium subclass:#PrinterContext
-	instanceVariableNames:'name abort jobid printerInfo'
+	instanceVariableNames:'name abort jobid printerInfo textAlign'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Printing'
@@ -408,21 +408,37 @@
 
 !PrinterContext methodsFor:'accessing'!
 
+container
+
+    ^self
+!
+
 getCharHeight
     "Private - answer the height of the font selected in the receiver's
      device context."
     
-    |textMetrics|
+    |textMetrics answer|
 
+    
     textMetrics := Win32OperatingSystem::TextMetricsStructure new.
-    (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ].
-    ^ textMetrics tmHeight + textMetrics tmExternalLeading
+"/    (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ].
+"/    Transcript showCR: 'CHAR HEIGHT PRIM ******* ', '   ',  (textMetrics tmHeight + textMetrics tmExternalLeading) printString.
+"/    Transcript showCR: 'CHAR HEIGHT DEVICE ***** ', '   ', (self font heightOf:'PQWEXCZ' on:self device) printString.
+    answer := (self font heightOf:'PQWEXCZ' on:self device).
+"/    answer := textMetrics tmHeight + textMetrics tmExternalLeading.
+    ^answer 
 
     "Created: / 02-08-2006 / 17:47:20 / fm"
     "Modified: / 03-08-2006 / 10:09:01 / fm"
     "Modified: / 10-10-2006 / 18:15:17 / cg"
 !
 
+horizontalPixelsPerMeter
+        "Answer horizontal pixels per meter
+        on the screen."
+    ^self pixelsPerInchOfScreenWidth  * 39.3700787
+!
+
 name
     "Answer the receiver's name from the current printerInfo."
     
@@ -447,6 +463,26 @@
     "Modified: / 10-10-2006 / 18:15:40 / cg"
 !
 
+physicalOffsetX
+
+        "Papierhöhe in Pixels"
+       "Changed by K3/EEZ3-Mg, 02.03.99"
+
+    ^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX"
+
+    "Created: / 01-08-2006 / 16:28:34 / fm"
+!
+
+physicalOffsetY
+
+        "Papierhöhe in Pixels"
+       "Changed by K3/EEZ3-Mg, 02.03.99"
+
+    ^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY"
+
+    "Created: / 01-08-2006 / 16:28:34 / fm"
+!
+
 pixelsPerInchOfScreenHeight
     ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy"
 
@@ -459,6 +495,12 @@
     "Created: / 01-08-2006 / 16:28:34 / fm"
 !
 
+printerHeightArea
+    ^ (OperatingSystem getDeviceCaps:gcId index:10)
+
+    "Modified: / 10-10-2006 / 18:18:31 / cg"
+!
+
 printerInfo
     "Answer the receiver's name from the current printerInfo."
     
@@ -488,6 +530,18 @@
     "Modified: / 10-10-2006 / 18:18:41 / cg"
 !
 
+printerPhysicalHeight
+    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:111 "PhysicalHeight"
+
+    "Created: / 01-08-2006 / 16:14:08 / fm"
+!
+
+printerPhysicalWidth
+    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:110 "PhysicalWidth"
+
+    "Created: / 01-08-2006 / 16:14:08 / fm"
+!
+
 printerUserFriendlyName
     "Answer the receiver's name from the current printerInfo."
     
@@ -495,6 +549,36 @@
 
     "Created: / 03-08-2006 / 12:55:57 / fm"
     "Modified: / 10-10-2006 / 18:18:55 / cg"
+!
+
+printerWidthArea
+    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres"
+
+    "Created: / 01-08-2006 / 16:14:08 / fm"
+!
+
+setTextAlign:aNumber
+
+"/    OperatingSystem setTextAlign: aNumber to: gcId.
+    textAlign :=aNumber.
+!
+
+setViewportOrg: aPoint
+
+    ^ OperatingSystem 
+            setViewportOrg: gcId "deviceContext"
+            x: aPoint x
+            y: aPoint y
+            oldOrigin: nil 
+
+    "Created: / 01-08-2006 / 16:14:08 / fm"
+!
+
+verticalPixelsPerMeter
+        "Answer vertical pixels per inch
+        on the screen."
+
+    ^self pixelsPerInchOfScreenHeight * 39.3700787
 ! !
 
 !PrinterContext methodsFor:'initialization & release'!
@@ -523,24 +607,15 @@
 
 initExtent
     "Private - init the width and height of GraphicsTool for the receiver."
-    
+
+    width := self printerWidthArea.
+    height := self printerHeightArea.
     device
-        width:self printerWidthArea;
-        height:self printerHeightArea
+        width:width;
+        height:height.
+    
 
     "Modified: / 01-08-2006 / 16:14:49 / fm"
-!
-
-printerHeightArea
-    ^ (OperatingSystem getDeviceCaps:gcId index:10)
-
-    "Modified: / 10-10-2006 / 18:18:31 / cg"
-!
-
-printerWidthArea
-    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres"
-
-    "Created: / 01-08-2006 / 16:14:08 / fm"
 ! !
 
 !PrinterContext methodsFor:'printing'!
@@ -832,7 +907,7 @@
 !
 
 supportsGraphics
-    ^(OperatingSystem getDeviceCaps: gcId asParameter index: 2 "Technology") ~= 4
+    ^(OperatingSystem getDeviceCaps: gcId "asParameter" index: 2 "Technology") ~= 4
 
     "Created: / 03-08-2006 / 10:07:43 / fm"
     "Modified: / 10-10-2006 / 18:21:14 / cg"
@@ -892,6 +967,37 @@
     "Modified: / 10-10-2006 / 18:14:00 / cg"
 !
 
+displayString:aString at:aPoint in:aRect options:ignoredForNow adx:unknownForNow
+    |x y|
+    x := aPoint x.
+    y := aPoint y.
+    (textAlign isNil or:[textAlign == 0 ]) ifTrue:[
+        self displayString:aString at:aPoint.
+        ^ self
+    ].
+    (textAlign == 8 "TaBottom") ifTrue:[
+        y := aPoint y - (self container font ascent) "container font ascent".
+    ] ifFalse:[ (textAlign == 6 "TaCenter") ifTrue:[
+        #TODO.
+"/        x := aRect left + ((aRect width-(container font widthOf:aString))//2).
+    ] ifFalse:[ (textAlign == 2 "TaRight") ifTrue:[
+        x := aRect right - (self "container font widthof:" stringWidthOf:aString).
+        y := self "container font ascent" getCharHeight + aPoint y .
+    ] ifFalse:[ (textAlign == 14 "TaCenterBottom") ifTrue:[
+        y := aRect bottom - self getCharHeight "container font ascent".
+        x := aRect left + ((aRect width-(self "container font widthOf:" stringWidthOf:aString))//2).
+    ] ifFalse:[ (textAlign == 10) ifTrue:[
+        x := aRect right - (self "container font widthof:" stringWidthOf:aString).
+        y := aRect bottom "aPoint y - (self container font ascent)" - self getCharHeight.
+    ]]]]].
+    Transcript showCR: 'Original Pos: ', aPoint x printString, '@', aPoint y printString,
+                       ' Pos: ', x printString, '@', y printString,
+                       ' Text: ', aString.
+    self displayString:aString at:(x@y).
+
+    "Modified: / 20-10-2006 / 13:53:44 / User"
+!
+
 displayStringLines:anIndexedCollection from:startIndex to:endIndex in:aRectangle 
     "Private - display Strings in anIndexedCollection starting at startIndex and
      ending at endIndex, clipped within the bounds of aRectangle."
@@ -945,6 +1051,11 @@
     "Modified: / 10-10-2006 / 18:14:40 / cg"
 !
 
+displayText: aString at: aPoint
+
+self displayString:aString x:aPoint x y:aPoint y
+!
+
 linesPerPageFor: aRectangle
 
 |marginsRect charHeight|
@@ -1069,6 +1180,8 @@
             string:str
             size:size) ifFalse:[ ^ self error ].
         answer := size x.
+"/        Transcript showCR: 'FROM PRIM ******* ', str, '   ',  answer printString.
+"/        Transcript showCR: 'FROM DEVICE ***** ', str, '   ',(self font widthOf:str on:self device) printString.
         #TODO.
     ] ifFalse:[
         answer := self font widthOf:str on:self device
@@ -1082,10 +1195,28 @@
     "Created: / 03-08-2006 / 10:27:20 / fm"
     "Modified: / 04-08-2006 / 12:27:26 / fm"
     "Modified: / 10-10-2006 / 18:20:43 / cg"
+!
+
+withLineStyle:aSymbol lineWidth:lw paint:paintColor do:aBlock
+    |savStyle savWidth savPaint|
+
+    savStyle := self lineStyle.
+    savWidth := self lineWidth.
+    savPaint := self paint.
+
+    self lineStyle:aSymbol.
+    self lineWidth:lw.
+    self paint:paintColor.
+    aBlock value.
+    self paint:savPaint.
+    self lineWidth:savWidth.
+    self lineStyle:savStyle.
+
+    "Created: / 13-09-2006 / 15:38:56 / User"
 ! !
 
 !PrinterContext class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/PrinterContext.st,v 1.8 2006-10-12 14:33:17 fm Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/PrinterContext.st,v 1.9 2006-11-15 09:15:41 fm Exp $'
 ! !