--- a/WinPrinterContext.st Tue Jul 19 07:10:19 2016 +0200
+++ b/WinPrinterContext.st Fri Jul 29 21:43:13 2016 +0100
@@ -14,7 +14,7 @@
"{ NameSpace: Smalltalk }"
PrinterContext subclass:#WinPrinterContext
- instanceVariableNames:'deviceFonts hatch supportsColor'
+ instanceVariableNames:'deviceFonts hatch supportsColor title'
classVariableNames:'PostScriptBlackWhite'
poolDictionaries:''
category:'Interface-Printing'
@@ -22,7 +22,7 @@
WinPrinterContext subclass:#WinPrinterGraphicContext
instanceVariableNames:'fontScale printPageNumbers pageNumberFormat pageCounter
- needsEndOfPage titleFont'
+ needsEndOfPage titleFont width height'
classVariableNames:''
poolDictionaries:''
privateIn:WinPrinterContext
@@ -299,7 +299,7 @@
gc := WinPrinterGraphicContext fromPrinterInfo:printerInfo.
gc notNil ifTrue:[
- gc startPrintJob:jobName
+ gc startPrintJob:jobName
].
^ gc
! !
@@ -5624,32 +5624,32 @@
drawn between startPrintJob and endPrintJob will become
one entry in the print queue."
- |docInfoStruct nameAddress title fileNameAddress|
+ |docInfoStruct nameAddress fileNameAddress|
self gcId isNil ifTrue:[
- self buildPrinter
+ self buildPrinter
].
abort := false.
title := aString ? 'Smalltalk/X'.
nameAddress := title asExternalBytes unprotectFromGC.
aFileName isNil ifFalse:[
- fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
+ fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
].
docInfoStruct := Win32OperatingSystem::DocInfoStructure new.
docInfoStruct
- cbSize:docInfoStruct sizeInBytes;
- lpszDocName:nameAddress address.
+ cbSize:docInfoStruct sizeInBytes;
+ lpszDocName:nameAddress address.
fileNameAddress isNil ifFalse:[
- docInfoStruct lpszOutput:fileNameAddress address
+ docInfoStruct lpszOutput:fileNameAddress address
].
jobid := OperatingSystem startDoc:self gcId docInfo:docInfoStruct.
jobid > 0 ifFalse:[
- jobid = -1 ifTrue:[
- abort := true.
- ^ nil
- ].
+ jobid = -1 ifTrue:[
+ abort := true.
+ ^ nil
+ ].
"/ ^ self error
- OpenError raiseErrorString:'Cannot create printer job'.
+ OpenError raiseErrorString:'Cannot create printer job'.
].
self startPage
@@ -5756,6 +5756,14 @@
^ 50
!
+extent
+ ^ width @ height
+!
+
+height
+ ^ height
+!
+
leftMargin
"return the papers left margin measured in pixels"
@@ -5772,6 +5780,10 @@
"return the papers top margin measured in pixels"
^ 50
+!
+
+width
+ ^ width
! !
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'accessing-hooks'!
@@ -5829,6 +5841,12 @@
super scale:(fontScale * (aScale ? 1.0)).
!
+scale:scale translation:aPoint
+ self
+ translation:aPoint;
+ scale:scale.
+!
+
transformation
"answer the transformation excluding the fontScale factor"
@@ -6059,12 +6077,14 @@
initialize
super initialize.
+ device := nil. "super initialize did set it to Screen current"
+
pageCounter := 0.
needsEndOfPage := false.
printPageNumbers := true.
Language == #de ifTrue:[ pageNumberFormat := 'Seite %1' ]
- ifFalse:[ pageNumberFormat := 'page %1' ].
+ ifFalse:[ pageNumberFormat := 'page %1' ].
! !
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'printing process'!
@@ -6074,7 +6094,7 @@
|oldClip oldTrans oldFont|
oldClip := gc clipingRectangleOrNil.
- oldClip notNil ifTrue:[ self deviceClippingRectangle:nil ].
+ oldClip notNil ifTrue:[ self deviceClippingBounds:nil ].
oldTrans := self translation.
oldFont := self font.
@@ -6086,7 +6106,7 @@
self translation:oldTrans.
oldFont notNil ifTrue:[ self font:oldFont ].
- oldClip notNil ifTrue:[ self deviceClippingRectangle:oldClip ].
+ oldClip notNil ifTrue:[ self deviceClippingBounds:oldClip ].
!
endPage
@@ -6096,18 +6116,21 @@
|s|
needsEndOfPage ifFalse:[
- ^ self
+ ^ self
].
needsEndOfPage := false.
printPageNumbers == true ifTrue:[
- self displayTitleDo:[
- s := pageNumberFormat bindWith:pageCounter.
-
- self displayString:s
+ self displayTitleDo:[
+ self displayString:title
+ x:(self extent x - (self font widthOf:title)) // 2
+ y:(self extent y + (self font ascent)).
+
+ s := pageNumberFormat bindWith:pageCounter.
+ self displayString:s
x:(self extent x - (self font widthOf:s))
y:(self extent y + (self font ascent)).
- ]
+ ]
].
super endPage.
!