WinPrinterStream.st
author Claus Gittinger <cg@exept.de>
Tue, 03 Sep 2013 17:23:55 +0200
changeset 3228 187a4158a51a
parent 3182 2eb2d9bafbb2
permissions -rw-r--r--
class: FlyByHelp changed: #initiateHelpFor:at:now: #showHelp:for: changed the flyBy suppression slightly: if the same text is to be shown again, do not show it except if the help is for another widget. (used to check for the text only previously)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     1
"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     3
              All Rights Reserved
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     4
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     5
 This software is furnished under a license and may be used
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     6
 only in accordance with the terms of that license and with the
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
     9
 other person.  No title to or ownership of the software is
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    10
 hereby transferred.
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    11
"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview2' }"
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
PrinterStream subclass:#WinPrinterStream
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'printerContext printJobName printFileName currentLineBuffer
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
    16
		currentPageBuffer cX cY colNr lineNr pageCount heightOfFont
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
    17
		jobStarted pageStarted'
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:'PrinterInfo'
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Interface-Printing'
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    23
!WinPrinterStream class methodsFor:'documentation'!
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    24
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    25
copyright
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    26
"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    27
 COPYRIGHT (c) 2006 by eXept Software AG
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    28
              All Rights Reserved
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    29
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    30
 This software is furnished under a license and may be used
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    31
 only in accordance with the terms of that license and with the
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    33
 be provided or otherwise made available to, or used by, any
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    34
 other person.  No title to or ownership of the software is
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    35
 hereby transferred.
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    36
"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    37
! !
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!WinPrinterStream class methodsFor:'instance creation'!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
new
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
    42
    | printerContext |
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    PrinterInfo := PrintingDialog getPrinterInfo.
2335
e2b7bbad49f6 care for escape in printer dialog
Claus Gittinger <cg@exept.de>
parents: 2302
diff changeset
    45
    PrinterInfo isNil ifTrue:[
e2b7bbad49f6 care for escape in printer dialog
Claus Gittinger <cg@exept.de>
parents: 2302
diff changeset
    46
        "/ cancelled
e2b7bbad49f6 care for escape in printer dialog
Claus Gittinger <cg@exept.de>
parents: 2302
diff changeset
    47
        AbortSignal raiseRequest.
e2b7bbad49f6 care for escape in printer dialog
Claus Gittinger <cg@exept.de>
parents: 2302
diff changeset
    48
        ^nil
e2b7bbad49f6 care for escape in printer dialog
Claus Gittinger <cg@exept.de>
parents: 2302
diff changeset
    49
    ].
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    51
    printerContext := WinPrinterContext fromPrinterInfo: PrinterInfo.
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    ^ self basicNew printerContext:printerContext.
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    55
    "Modified: / 12-10-2006 / 10:07:36 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    56
    "Modified: / 16-04-2007 / 12:58:13 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
newForFile:aFileNameOrNil
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    "return a new stream for printing into aFileName"
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    |printer|
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    printer := self basicNew initialize.
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    printer setPrintFileName:aFileNameOrNil.
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    printer startPrint.
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    ^ printer
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    69
    "Modified: / 12-10-2006 / 14:35:09 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
    70
    "Modified: / 16-04-2007 / 12:58:18 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
newNative
3182
2eb2d9bafbb2 class: WinPrinterStream
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
    74
    self halt:'unimplemented feature'
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
! !
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
2889
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    77
!WinPrinterStream class methodsFor:'class initialization'!
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    78
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    79
initialize
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    80
    "in some configurations (expecco), libview2 is loaded lazy and later,
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    81
     and the printer is setup to be PrinterStream (which is stupid).
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    82
     Here, we install ourself."
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    83
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    84
    (Printer isNil or:[Printer == PrinterStream]) ifTrue:[
3037
86ef45ddef74 class: WinPrinterStream
Stefan Vogel <sv@exept.de>
parents: 2984
diff changeset
    85
        OperatingSystem isMSWINDOWSlike ifTrue:[
86ef45ddef74 class: WinPrinterStream
Stefan Vogel <sv@exept.de>
parents: 2984
diff changeset
    86
            "don't change printer, if simply autoloading this class in linux"
86ef45ddef74 class: WinPrinterStream
Stefan Vogel <sv@exept.de>
parents: 2984
diff changeset
    87
            Printer := self.
86ef45ddef74 class: WinPrinterStream
Stefan Vogel <sv@exept.de>
parents: 2984
diff changeset
    88
        ].
2889
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    89
    ].
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    90
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    91
    "Created: / 09-02-2011 / 13:46:27 / cg"
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    92
! !
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
    93
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
!WinPrinterStream class methodsFor:'queries'!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
isDrivenByCommand
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    "return true if this printer is driven via an OS-command
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
     (as opposed to writing a file or using a native printing API)"
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ^ false
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    "Created: / 10-10-2006 / 18:22:13 / cg"
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
printerTypeName
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    "return a descriptive name"
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
2346
e5a41923ac0c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   108
    ^ 'Windows Printer'
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    "Created: / 10-10-2006 / 18:26:22 / cg"
2346
e5a41923ac0c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   111
    "Modified: / 08-11-2007 / 12:13:59 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
2984
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   114
supportsContext
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   115
    ^ true
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   116
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   117
    "Created: / 31-01-2012 / 18:15:44 / cg"
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   118
!
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   119
2450
330fb7f2b5ab +supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents: 2346
diff changeset
   120
supportsPrintingToCommand
330fb7f2b5ab +supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents: 2346
diff changeset
   121
    ^ false
330fb7f2b5ab +supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents: 2346
diff changeset
   122
330fb7f2b5ab +supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents: 2346
diff changeset
   123
    "Created: / 10-10-2006 / 18:27:16 / cg"
330fb7f2b5ab +supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents: 2346
diff changeset
   124
!
330fb7f2b5ab +supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents: 2346
diff changeset
   125
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
supportsPrintingToFile
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ^ false
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    "Created: / 10-10-2006 / 18:27:16 / cg"
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
! !
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
!WinPrinterStream methodsFor:'accessing'!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   134
fontWidthForTabComputing
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   135
    ^ 120
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   136
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   137
    "Created: / 12-10-2006 / 11:59:33 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   138
    "Modified: / 16-04-2007 / 13:00:05 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   139
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   140
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   141
hasJobStarted
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   142
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   143
    ^jobStarted = true
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   144
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   145
    "Created: / 12-10-2006 / 14:38:00 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   146
    "Modified: / 16-04-2007 / 13:00:26 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   147
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   148
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   149
hasPageStarted
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   150
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   151
    ^pageStarted = true
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   152
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   153
    "Created: / 12-10-2006 / 14:41:39 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   154
    "Modified: / 16-04-2007 / 13:00:32 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   155
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   156
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   157
heightOfFont
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   158
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   159
    heightOfFont isNil ifTrue:[heightOfFont := printerContext getCharHeight].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   160
    ^heightOfFont
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   161
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   162
    "Created: / 12-10-2006 / 12:00:57 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   163
    "Modified: / 16-04-2007 / 13:00:35 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   164
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   165
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   166
linesPerPage
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   167
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   168
    ^printerContext linesPerPageFor: nil
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   169
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   170
    "Created: / 12-10-2006 / 11:57:53 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   171
    "Modified: / 16-04-2007 / 13:00:38 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   172
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   173
2984
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   174
printerContext
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   175
    ^ printerContext
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   176
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   177
    "Created: / 31-01-2012 / 18:13:54 / cg"
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   178
!
a0d6401b9412 font setting support
Claus Gittinger <cg@exept.de>
parents: 2889
diff changeset
   179
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
printerContext:something
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    printerContext := something.
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
! !
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
!WinPrinterStream methodsFor:'open/close'!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   186
endPage
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   187
    printerContext endPage.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   188
    pageStarted := false.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   189
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   190
    "Created: / 12-10-2006 / 14:42:18 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   191
    "Modified: / 16-04-2007 / 12:58:33 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   192
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   193
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
endPrint
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    printerContext endPrintJob.
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   196
    jobStarted := false.
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    "Created: / 10-10-2006 / 18:50:05 / cg"
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   199
    "Modified: / 12-10-2006 / 14:41:11 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   200
    "Modified: / 16-04-2007 / 12:58:36 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   201
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   202
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   203
formFeed
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   204
    printerContext formFeed.
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   205
    self resetPage
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   206
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   207
    "Created: / 12-10-2006 / 10:41:40 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   208
    "Modified: / 12-10-2006 / 14:40:53 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   209
    "Modified: / 16-04-2007 / 13:00:21 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   210
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   211
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   212
startPage
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   213
    printerContext startPage.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   214
    pageStarted := true.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   215
    self resetPage
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   216
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   217
    "Created: / 12-10-2006 / 14:39:27 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   218
    "Modified: / 16-04-2007 / 13:00:58 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
startPrint
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    printerContext isNil ifTrue:[
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
        PrinterInfo isNil ifTrue:[
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
            PrinterInfo := PrintingDialog getPrinterInfo.
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
            PrinterInfo isNil ifTrue:[^self].
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
        ].
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   227
        printerContext := WinPrinterContext fromPrinterInfo: PrinterInfo.
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    ].
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   229
    printerContext foreground:(Color black) background:(Color white).
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   230
    self resetPage.
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    printerContext startPrintJob: (printJobName ? 'ST/X PrintJob') fileName:printFileName.
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   232
    pageCount := 1.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   233
    jobStarted := true.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   234
    pageStarted := true.
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "Created: / 10-10-2006 / 18:49:55 / cg"
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   237
    "Modified: / 12-10-2006 / 15:25:29 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   238
    "Modified: / 16-04-2007 / 13:01:01 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
! !
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
!WinPrinterStream methodsFor:'private'!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   243
resetPage
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   244
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   245
    cX := cY := colNr := lineNr := 0.
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   246
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   247
    "Created: / 12-10-2006 / 14:40:23 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   248
    "Modified: / 16-04-2007 / 13:00:52 / cg"
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   249
!
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   250
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
setPrintFileName:something
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    printFileName := something.
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    "Created: / 10-10-2006 / 19:07:16 / cg"
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
! !
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
!WinPrinterStream methodsFor:'writing'!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
cr
2563
fde293484ef5 lazy init fixed
Claus Gittinger <cg@exept.de>
parents: 2550
diff changeset
   260
    self hasJobStarted ifFalse:[self startPrint].
fde293484ef5 lazy init fixed
Claus Gittinger <cg@exept.de>
parents: 2550
diff changeset
   261
    self hasPageStarted ifFalse:[self startPage].
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   263
    colNr := 0.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   264
    lineNr := lineNr + 1.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   265
    cX := 0 "+ self leftX".
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   266
    cY := cY + self heightOfFont.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   267
    lineNr >= self linesPerPage ifTrue:[
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   268
            pageCount := pageCount + 1.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   269
            self endPage
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    ].
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   272
    "Modified: / 12-10-2006 / 14:42:57 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   273
    "Modified: / 16-04-2007 / 12:58:30 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
nextPut:aCharacter
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   277
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   278
    self hasJobStarted ifFalse:[self startPrint].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   279
    self hasPageStarted ifFalse:[self startPage].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   280
2591
6bfb23a13a3a asciiValue obsoleted by codePoint
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   281
    aCharacter codePoint < 16r20 ifTrue:[
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   282
        aCharacter == Character cr ifTrue:[
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   283
            self cr.    
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   284
        ].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   285
        aCharacter == Character tab ifTrue:[
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   286
           colNr := ((colNr + 8) // 8) * 8. 
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   287
           cX := "self leftX +" (colNr * self fontWidthForTabComputing).
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   288
           ^ self
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   289
        ].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   290
        aCharacter == Character newPage ifTrue:[
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   291
            self endPage. 
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   292
        ].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   293
        ^ self.
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
    ].
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   296
    printerContext displayString:aCharacter asString x:cX y:cY.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   297
    colNr := colNr + 1.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   298
    cX := cX + (printerContext stringWidthOf: aCharacter asString).
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   299
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   300
    "Modified: / 12-10-2006 / 15:06:14 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   301
    "Modified: / 16-04-2007 / 13:00:44 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
nextPutAll:aString
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   305
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   306
    self hasJobStarted ifFalse:[self startPrint].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   307
    self hasPageStarted ifFalse:[self startPage].
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   308
2591
6bfb23a13a3a asciiValue obsoleted by codePoint
Claus Gittinger <cg@exept.de>
parents: 2563
diff changeset
   309
    (aString contains:[:char | char codePoint < 16r20]) ifTrue:[
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   310
        super nextPutAll:aString.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   311
        ^ self.
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    ].
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
2248
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   314
    #TODO. "/ use aString, when problem with Text-extent is fixed... 
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   315
    printerContext displayString: aString string x:cX y:cY.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   316
    colNr := colNr + aString size.
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   317
    cX := cX + (printerContext stringWidthOf: aString string).
bb624c6d4709 Simple Windows Stream Printing Support
fm
parents: 2238
diff changeset
   318
2302
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   319
    "Modified: / 12-10-2006 / 15:21:02 / fm"
a36ea047f05b code cleanup
Claus Gittinger <cg@exept.de>
parents: 2248
diff changeset
   320
    "Modified: / 16-04-2007 / 13:00:46 / cg"
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
! !
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
!WinPrinterStream class methodsFor:'documentation'!
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
version
3182
2eb2d9bafbb2 class: WinPrinterStream
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
   326
    ^ '$Header: /cvs/stx/stx/libview2/WinPrinterStream.st,v 1.13 2013-06-20 14:57:19 cg Exp $'
2889
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   327
!
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   328
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   329
version_CVS
3182
2eb2d9bafbb2 class: WinPrinterStream
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
   330
    ^ '$Header: /cvs/stx/stx/libview2/WinPrinterStream.st,v 1.13 2013-06-20 14:57:19 cg Exp $'
2238
b481888ed173 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
! !
2889
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   332
3182
2eb2d9bafbb2 class: WinPrinterStream
Claus Gittinger <cg@exept.de>
parents: 3037
diff changeset
   333
2889
d2055a8b1055 added: #initialize
Claus Gittinger <cg@exept.de>
parents: 2591
diff changeset
   334
WinPrinterStream initialize!