2238
|
1 |
"{ Package: 'stx:libview2' }"
|
|
2 |
|
|
3 |
PrinterStream subclass:#WinPrinterStream
|
|
4 |
instanceVariableNames:'printerContext printJobName printFileName currentLineBuffer
|
|
5 |
currentPageBuffer'
|
|
6 |
classVariableNames:'PrinterInfo'
|
|
7 |
poolDictionaries:''
|
|
8 |
category:'Interface-Printing'
|
|
9 |
!
|
|
10 |
|
|
11 |
|
|
12 |
!WinPrinterStream class methodsFor:'instance creation'!
|
|
13 |
|
|
14 |
new
|
|
15 |
| printerInfo printerContext |
|
|
16 |
|
|
17 |
PrinterInfo := PrintingDialog getPrinterInfo.
|
|
18 |
PrinterInfo isNil ifTrue:[^self].
|
|
19 |
|
|
20 |
printerContext := PrinterContext fromPrinterInfo: PrinterInfo.
|
|
21 |
|
|
22 |
^ self basicNew printerContext:printerContext.
|
|
23 |
|
|
24 |
"Modified: / 10-10-2006 / 18:47:18 / cg"
|
|
25 |
!
|
|
26 |
|
|
27 |
newForFile:aFileNameOrNil
|
|
28 |
"return a new stream for printing into aFileName"
|
|
29 |
|
|
30 |
|printer|
|
|
31 |
|
|
32 |
printer := self basicNew initialize.
|
|
33 |
printer setPrintFileName:aFileNameOrNil.
|
|
34 |
printer startPrint.
|
|
35 |
^ printer
|
|
36 |
|
|
37 |
"Modified: / 10-10-2006 / 19:08:52 / cg"
|
|
38 |
!
|
|
39 |
|
|
40 |
newNative
|
|
41 |
self halt
|
|
42 |
|
|
43 |
"Created: / 10-10-2006 / 18:41:39 / cg"
|
|
44 |
! !
|
|
45 |
|
|
46 |
!WinPrinterStream class methodsFor:'queries'!
|
|
47 |
|
|
48 |
isDrivenByCommand
|
|
49 |
"return true if this printer is driven via an OS-command
|
|
50 |
(as opposed to writing a file or using a native printing API)"
|
|
51 |
|
|
52 |
^ false
|
|
53 |
|
|
54 |
"Created: / 10-10-2006 / 18:22:13 / cg"
|
|
55 |
!
|
|
56 |
|
|
57 |
printerTypeName
|
|
58 |
"return a descriptive name"
|
|
59 |
|
|
60 |
^ 'windows printer'
|
|
61 |
|
|
62 |
"Created: / 10-10-2006 / 18:26:22 / cg"
|
|
63 |
!
|
|
64 |
|
|
65 |
supportsPrintingToFile
|
|
66 |
^ false
|
|
67 |
|
|
68 |
"Created: / 10-10-2006 / 18:27:16 / cg"
|
|
69 |
! !
|
|
70 |
|
|
71 |
!WinPrinterStream methodsFor:'accessing'!
|
|
72 |
|
|
73 |
printerContext:something
|
|
74 |
printerContext := something.
|
|
75 |
! !
|
|
76 |
|
|
77 |
!WinPrinterStream methodsFor:'open/close'!
|
|
78 |
|
|
79 |
endPrint
|
|
80 |
printerContext endPrintJob.
|
|
81 |
|
|
82 |
"Created: / 10-10-2006 / 18:50:05 / cg"
|
|
83 |
!
|
|
84 |
|
|
85 |
startPrint
|
|
86 |
printerContext isNil ifTrue:[
|
|
87 |
PrinterInfo isNil ifTrue:[
|
|
88 |
PrinterInfo := PrintingDialog getPrinterInfo.
|
|
89 |
PrinterInfo isNil ifTrue:[^self].
|
|
90 |
].
|
|
91 |
printerContext := PrinterContext fromPrinterInfo: PrinterInfo.
|
|
92 |
].
|
|
93 |
|
|
94 |
printerContext startPrintJob: (printJobName ? 'ST/X PrintJob') fileName:printFileName.
|
|
95 |
printerContext foreground:(Color black) background:(Color white).
|
|
96 |
|
|
97 |
"Created: / 10-10-2006 / 18:49:55 / cg"
|
|
98 |
! !
|
|
99 |
|
|
100 |
!WinPrinterStream methodsFor:'private'!
|
|
101 |
|
|
102 |
setPrintFileName:something
|
|
103 |
printFileName := something.
|
|
104 |
|
|
105 |
"Created: / 10-10-2006 / 19:07:16 / cg"
|
|
106 |
! !
|
|
107 |
|
|
108 |
!WinPrinterStream methodsFor:'writing'!
|
|
109 |
|
|
110 |
cr
|
|
111 |
|line|
|
|
112 |
|
|
113 |
currentLineBuffer notNil ifTrue:[
|
|
114 |
line := currentLineBuffer contents.
|
|
115 |
currentLineBuffer := nil.
|
|
116 |
].
|
|
117 |
|
|
118 |
currentPageBuffer isNil ifTrue:[
|
|
119 |
currentPageBuffer := OrderedCollection new.
|
|
120 |
].
|
|
121 |
currentPageBuffer add:line.
|
|
122 |
|
|
123 |
"Created: / 10-10-2006 / 20:19:46 / cg"
|
|
124 |
!
|
|
125 |
|
|
126 |
nextPut:aCharacter
|
|
127 |
currentLineBuffer isNil ifTrue:[
|
|
128 |
currentLineBuffer := WriteStream on:String new.
|
|
129 |
].
|
|
130 |
currentLineBuffer nextPut:aCharacter
|
|
131 |
|
|
132 |
"Created: / 10-10-2006 / 20:18:09 / cg"
|
|
133 |
!
|
|
134 |
|
|
135 |
nextPutAll:aString
|
|
136 |
currentLineBuffer isNil ifTrue:[
|
|
137 |
currentLineBuffer := WriteStream on:String new.
|
|
138 |
].
|
|
139 |
currentLineBuffer nextPutAll:aString
|
|
140 |
|
|
141 |
"Created: / 10-10-2006 / 20:18:33 / cg"
|
|
142 |
! !
|
|
143 |
|
|
144 |
!WinPrinterStream class methodsFor:'documentation'!
|
|
145 |
|
|
146 |
version
|
|
147 |
^ '$Header: /cvs/stx/stx/libview2/WinPrinterStream.st,v 1.1 2006-10-10 18:26:19 cg Exp $'
|
|
148 |
! !
|