PrinterContext.st
author Claus Gittinger <cg@exept.de>
Tue, 10 Oct 2006 18:22:07 +0200
changeset 2236 76291d984db9
parent 2235 0df6bda4b353
child 2237 950fb103a14e
permissions -rw-r--r--
pretty printing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2184
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     1
"
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     3
              All Rights Reserved
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     4
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     5
 This software is furnished under a license and may be used
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     6
 only in accordance with the terms of that license and with the
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     9
 other person.  No title to or ownership of the software is
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    10
 hereby transferred.
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    11
"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    12
"{ Package: 'stx:libview2' }"
8f5996be6907 initial checkin
fm
parents:
diff changeset
    13
8f5996be6907 initial checkin
fm
parents:
diff changeset
    14
GraphicsMedium subclass:#PrinterContext
8f5996be6907 initial checkin
fm
parents:
diff changeset
    15
	instanceVariableNames:'name abort jobid printerInfo'
8f5996be6907 initial checkin
fm
parents:
diff changeset
    16
	classVariableNames:''
8f5996be6907 initial checkin
fm
parents:
diff changeset
    17
	poolDictionaries:''
8f5996be6907 initial checkin
fm
parents:
diff changeset
    18
	category:'Interface-Printing'
8f5996be6907 initial checkin
fm
parents:
diff changeset
    19
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
    20
2184
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    21
!PrinterContext class methodsFor:'documentation'!
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    22
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    23
copyright
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    24
"
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    25
 COPYRIGHT (c) 2006 by eXept Software AG
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    26
              All Rights Reserved
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    27
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    28
 This software is furnished under a license and may be used
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    29
 only in accordance with the terms of that license and with the
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    31
 be provided or otherwise made available to, or used by, any
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    32
 other person.  No title to or ownership of the software is
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    33
 hereby transferred.
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    34
"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    35
!
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    36
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    37
documentation
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    38
"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    39
    I am the mediator between the smalltalk printing protocol 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    40
    (which is the same as the graphics drawing protocol) and the
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    41
    windows printer.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    42
    When youopena printer, you will typically talk to me, and I will
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    43
    forward the graphics commands to my printer.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    44
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    45
    [author:]
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    46
        Felix Madrid (fm@exept.de)
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    47
"
2184
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    48
! !
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    49
8f5996be6907 initial checkin
fm
parents:
diff changeset
    50
!PrinterContext class methodsFor:'instance creation'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
    51
8f5996be6907 initial checkin
fm
parents:
diff changeset
    52
fromPrinterInfo: aPrinterInfo
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    53
    "Private - Answer a Printer object given an hDC"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    54
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    55
    | aPrinter hDC|     
8f5996be6907 initial checkin
fm
parents:
diff changeset
    56
8f5996be6907 initial checkin
fm
parents:
diff changeset
    57
    hDC := aPrinterInfo createDC.
8f5996be6907 initial checkin
fm
parents:
diff changeset
    58
    hDC = 0 ifTrue: [ ^self error: 'Error while opening printer.' ].
8f5996be6907 initial checkin
fm
parents:
diff changeset
    59
    aPrinter := self new.
8f5996be6907 initial checkin
fm
parents:
diff changeset
    60
    aPrinter printerInfo: aPrinterInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
    61
    aPrinter setDevice:(WinPrinter on: aPrinterInfo) id:nil gcId:hDC.
8f5996be6907 initial checkin
fm
parents:
diff changeset
    62
    aPrinter initExtent.
8f5996be6907 initial checkin
fm
parents:
diff changeset
    63
    ^aPrinter
8f5996be6907 initial checkin
fm
parents:
diff changeset
    64
8f5996be6907 initial checkin
fm
parents:
diff changeset
    65
    "Created: / 03-08-2006 / 12:53:52 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
    66
    "Modified: / 04-08-2006 / 12:55:01 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    67
    "Modified: / 10-10-2006 / 17:32:59 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    68
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
    69
8f5996be6907 initial checkin
fm
parents:
diff changeset
    70
printWith: aRecordingPen
8f5996be6907 initial checkin
fm
parents:
diff changeset
    71
        "Print the contents of aRecordingPen on
8f5996be6907 initial checkin
fm
parents:
diff changeset
    72
         the system printer."
8f5996be6907 initial checkin
fm
parents:
diff changeset
    73
    self new drawUsing: aRecordingPen
8f5996be6907 initial checkin
fm
parents:
diff changeset
    74
8f5996be6907 initial checkin
fm
parents:
diff changeset
    75
    "Created: / 27-07-2006 / 17:53:59 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
    76
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
    77
8f5996be6907 initial checkin
fm
parents:
diff changeset
    78
!PrinterContext class methodsFor:'accessing'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
    79
8f5996be6907 initial checkin
fm
parents:
diff changeset
    80
default
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    81
    "Answer the default Printer, or nil if none."
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    82
    
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    83
    |defaultName|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    84
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    85
    ^ (defaultName := self defaultPrinterName) isNil 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    86
        ifTrue:[ nil ]
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    87
        ifFalse:[ self named:defaultName ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    88
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    89
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    90
     self default
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    91
    "
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    92
8f5996be6907 initial checkin
fm
parents:
diff changeset
    93
    "Created: / 27-07-2006 / 17:51:43 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
    94
    "Modified: / 02-08-2006 / 17:27:09 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    95
    "Modified: / 10-10-2006 / 17:30:31 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    96
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
    97
8f5996be6907 initial checkin
fm
parents:
diff changeset
    98
defaultMargins
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    99
    "Private - answer aPoint containing the default horizontal and vertical
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   100
     margins for a page (units in inches)."
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   101
    
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   102
    ^ 0.5 @ 0.75
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   103
8f5996be6907 initial checkin
fm
parents:
diff changeset
   104
    "Created: / 01-08-2006 / 16:09:31 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   105
    "Modified: / 10-10-2006 / 17:30:49 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   106
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   107
8f5996be6907 initial checkin
fm
parents:
diff changeset
   108
defaultPrinterName
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   109
    "Answer the name of the default printer, or nil if none."
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   110
    
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   111
    |printerInfo printerName|
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   112
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   113
    printerInfo := OperatingSystem getDefaultPrinterName.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   114
    printerName := (printerInfo copyFrom:1 to:(printerInfo indexOf:$,) - 1) trimBlanks.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   115
    ^ printerName size == 0 ifTrue:[ nil ] ifFalse:[ printerName ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   116
8f5996be6907 initial checkin
fm
parents:
diff changeset
   117
    "
8f5996be6907 initial checkin
fm
parents:
diff changeset
   118
     PrinterContext defaultPrinterName
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   119
    "
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   120
8f5996be6907 initial checkin
fm
parents:
diff changeset
   121
    "Modified: / 02-08-2006 / 17:26:09 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   122
    "Modified: / 10-10-2006 / 17:32:45 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   123
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   124
8f5996be6907 initial checkin
fm
parents:
diff changeset
   125
getPrinterInformation: printerNameString
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   126
    " Answer the printer information for the printer named printerNameString.  If no name is specified,
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   127
      answer the information for the default printer. "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   128
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   129
    | h |
8f5996be6907 initial checkin
fm
parents:
diff changeset
   130
8f5996be6907 initial checkin
fm
parents:
diff changeset
   131
     h := OperatingSystem openPrinter: printerNameString.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   132
     ^OperatingSystem getDocumentProperties:nil hPrinter:h pDeviceName: printerNameString .
8f5996be6907 initial checkin
fm
parents:
diff changeset
   133
8f5996be6907 initial checkin
fm
parents:
diff changeset
   134
    "Created: / 27-07-2006 / 10:22:32 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   135
    "Modified: / 01-08-2006 / 16:01:44 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   136
    "Modified: / 10-10-2006 / 17:33:07 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   137
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   138
8f5996be6907 initial checkin
fm
parents:
diff changeset
   139
named: aName
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   140
    "Answer a new instance of Printer which represents
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   141
     the printer named aName as specified in the host
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   142
     Control Panel."
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   143
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   144
    aName isNil ifTrue: [ ^self default ].
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   145
    ^self new printerInfoWithName: aName
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   146
8f5996be6907 initial checkin
fm
parents:
diff changeset
   147
    "Created: / 27-07-2006 / 17:51:27 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   148
    "Modified: / 02-08-2006 / 17:26:29 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   149
    "Modified: / 10-10-2006 / 17:33:29 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   150
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   151
8f5996be6907 initial checkin
fm
parents:
diff changeset
   152
printerNames
8f5996be6907 initial checkin
fm
parents:
diff changeset
   153
        "Answer a collection of all known printer names."
8f5996be6907 initial checkin
fm
parents:
diff changeset
   154
8f5996be6907 initial checkin
fm
parents:
diff changeset
   155
    ^OperatingSystem getPrintersNames
8f5996be6907 initial checkin
fm
parents:
diff changeset
   156
8f5996be6907 initial checkin
fm
parents:
diff changeset
   157
    "Created: / 27-07-2006 / 17:54:45 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   158
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   159
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   160
!PrinterContext class methodsFor:'testing & examples'!
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   161
8f5996be6907 initial checkin
fm
parents:
diff changeset
   162
print: aString font: aFont title: aTitle
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   163
    "Open a print dialog to allow printing of the given string
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   164
     using the given title & font."
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   165
8f5996be6907 initial checkin
fm
parents:
diff changeset
   166
    self print: aString font: aFont title: aTitle wordWrap: false     
8f5996be6907 initial checkin
fm
parents:
diff changeset
   167
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   168
   "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   169
    PrinterContext print: 'Holaaaa!! (from:  PrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test'
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   170
    PrinterContext print: self printingTestString font: nil title: 'Printing Test String'
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   171
    PrinterContext print: self printingTestString font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String'
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   172
   "
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   173
8f5996be6907 initial checkin
fm
parents:
diff changeset
   174
    "Created: / 27-07-2006 / 17:52:33 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   175
    "Modified: / 03-08-2006 / 18:52:31 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   176
    "Modified: / 10-10-2006 / 17:37:49 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   177
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   178
8f5996be6907 initial checkin
fm
parents:
diff changeset
   179
print: aString font: aFont title: aTitle wordWrap: wordWrap
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   180
    "Open a print dialog to allow printing of the given string
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   181
     using the given title & font."
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   182
8f5996be6907 initial checkin
fm
parents:
diff changeset
   183
    | printerInfo printer |
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   184
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   185
    printerInfo := PrintingDialog getPrinterInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   186
    printerInfo isNil ifTrue:[^self].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   187
8f5996be6907 initial checkin
fm
parents:
diff changeset
   188
    printer := self fromPrinterInfo: printerInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   189
    [ 
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   190
        printer
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   191
            print: aString
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   192
            font: aFont
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   193
            title: aTitle 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   194
            wordWrap: wordWrap
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   195
            marginsRect: nil 
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   196
    ] forkAt: 3
8f5996be6907 initial checkin
fm
parents:
diff changeset
   197
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   198
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   199
     PrinterContext print: 'Holaaaa!! (from:  PrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test' wordWrap: true
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   200
     PrinterContext print: (PrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font:nil title:'Printing Test String' wordWrap:true
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   201
     PrinterContext print: (PrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String' wordWrap: true
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   202
    "
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   203
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   204
    "Created: / 03-08-2006 / 18:51:53 / fm"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   205
    "Modified: / 10-10-2006 / 17:42:06 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   206
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   207
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   208
printCircles: arrayOfPointsAndRadius
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   209
    "Opens a print dialog and prints the given circles"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   210
8f5996be6907 initial checkin
fm
parents:
diff changeset
   211
    | printerInfo printer |
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   212
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   213
    printerInfo := PrintingDialog getPrinterInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   214
    printerInfo isNil ifTrue:[^self].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   215
8f5996be6907 initial checkin
fm
parents:
diff changeset
   216
    printer := self fromPrinterInfo: printerInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   217
    [ 
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   218
        printer startPrintJob: 'Circles'.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   219
        arrayOfPointsAndRadius
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   220
            do:[:pointAndRadius |
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   221
                printer displayCircle:(pointAndRadius at:1) 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   222
                        radius:(pointAndRadius at:2).
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   223
            ].
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   224
        printer endPrintJob.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   225
    ] forkAt: 3
8f5996be6907 initial checkin
fm
parents:
diff changeset
   226
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   227
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   228
     PrinterContext printCircles:  
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   229
        (Array with: (Array with: 800@800 with: 600)
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   230
               with: (Array with: 1500@1500 with: 1000)
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   231
               with: (Array with: 4000@2500 with: 2000))
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   232
    "
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   233
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   234
    "Created: / 07-08-2006 / 11:46:52 / fm"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   235
    "Modified: / 10-10-2006 / 17:36:23 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   236
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   237
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   238
printCirclesIn: rectangles
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   239
    "Opens a print dialog and prints the given circles"
2146
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   240
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   241
    | printerInfo printer |
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   242
2146
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   243
    printerInfo := PrintingDialog getPrinterInfo.
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   244
    printerInfo isNil ifTrue:[^self].
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   245
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   246
    printer := self fromPrinterInfo: printerInfo.
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   247
    [ 
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   248
        printer startPrintJob: 'Circles In Rectangles'.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   249
        rectangles
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   250
           do:[:rectangle |
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   251
               printer displayCircleIn: rectangle.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   252
           ].
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   253
       printer endPrintJob.
2146
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   254
    ] forkAt: 3
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   255
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   256
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   257
     PrinterContext printCirclesIn:  
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   258
        (Array with: (Rectangle left:20 top:20 width:400 height:600)
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   259
               with: (Rectangle left:40 top:40 width:600 height:400)    
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   260
        )
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   261
    "
2146
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   262
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   263
    "Created: / 07-08-2006 / 11:48:46 / fm"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   264
    "Modified: / 10-10-2006 / 17:38:28 / cg"
2146
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   265
!
61291b6cc0f7 add line printing support
fm
parents: 2143
diff changeset
   266
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   267
printLines: pairOfPointsArray
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   268
    "Opens a print dialog and prints the given lines"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   269
8f5996be6907 initial checkin
fm
parents:
diff changeset
   270
    | printerInfo printer |
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   271
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   272
    printerInfo := PrintingDialog getPrinterInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   273
    printerInfo isNil ifTrue:[^self].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   274
8f5996be6907 initial checkin
fm
parents:
diff changeset
   275
    printer := self fromPrinterInfo: printerInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   276
    [ 
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   277
        printer startPrintJob: 'Lines'.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   278
        printer foreground:Color black background:Color white.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   279
        pairOfPointsArray
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   280
            do:[:pairOfPoints |                 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   281
                 printer displayLineFrom: (pairOfPoints at:1)  to: (pairOfPoints at:2).
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   282
            ].
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   283
        printer endPrintJob.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   284
    ] forkAt: 3
8f5996be6907 initial checkin
fm
parents:
diff changeset
   285
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   286
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   287
     PrinterContext printLines:  
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   288
        (Array with: (Array with:10@10 with:100@10)
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   289
               with: (Array with:10@10 with:35@200))
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   290
    "
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   291
8f5996be6907 initial checkin
fm
parents:
diff changeset
   292
    "Created: / 07-08-2006 / 12:09:48 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   293
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   294
    "Modified: / 10-10-2006 / 17:38:44 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   295
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   296
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   297
printPolygons: polygons
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   298
    "Opens a print dialog and prints the given polygons"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   299
8f5996be6907 initial checkin
fm
parents:
diff changeset
   300
    | printerInfo printer |
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   301
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   302
    printerInfo := PrintingDialog getPrinterInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   303
    printerInfo isNil ifTrue:[^self].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   304
8f5996be6907 initial checkin
fm
parents:
diff changeset
   305
    printer := self fromPrinterInfo: printerInfo.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   306
    [ 
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   307
        printer startPrintJob: 'Polygons'.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   308
        printer foreground:Color black background:Color white.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   309
        polygons
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   310
            do:[:aPolygon |
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   311
                 aPolygon displayStrokedOn: printer.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   312
            ].
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   313
        printer endPrintJob.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   314
    ] forkAt: 3
8f5996be6907 initial checkin
fm
parents:
diff changeset
   315
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   316
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   317
     PrinterContext printPolygons:  
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   318
        (Array with: (Polygon vertices:(
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   319
                                Array
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   320
                                    with:10@10
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   321
                                    with:60@10
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   322
                                    with:35@60)))
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   323
    "
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   324
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   325
    "Created: / 07-08-2006 / 12:09:48 / fm"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   326
    "Modified: / 07-08-2006 / 14:11:17 / fm"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   327
    "Modified: / 10-10-2006 / 17:39:23 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   328
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   329
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   330
printRectangles: rectangles
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   331
    "Opens a print dialog and prints the given rectangles"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   332
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   333
    | printerInfo printer |
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   334
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   335
    printerInfo := PrintingDialog getPrinterInfo.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   336
    printerInfo isNil ifTrue:[^self].
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   337
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   338
    printer := self fromPrinterInfo: printerInfo.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   339
    [ 
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   340
        printer startPrintJob: 'Rectangles'.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   341
        rectangles 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   342
            do:[:rectangle |
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   343
                printer displayRectangleX: rectangle origin x 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   344
                        y: rectangle origin y 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   345
                        width: rectangle width 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   346
                        height: rectangle height.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   347
            ].
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   348
        printer endPrintJob.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   349
    ] forkAt: 3
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   350
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   351
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   352
     PrinterContext printRectangles:  
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   353
        (Array with: (Rectangle left:20 top:20 width:400 height:600)
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   354
               with: (Rectangle left:40 top:40 width:600 height:400)    
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   355
        )
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   356
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   357
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   358
    "Created: / 07-08-2006 / 11:40:48 / fm"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   359
    "Modified: / 10-10-2006 / 17:39:51 / cg"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   360
!
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   361
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   362
printStrings: stringAndPositionsArray
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   363
    "Opens a print dialog and prints the given strings"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   364
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   365
    | printerInfo printer |
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   366
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   367
    printerInfo := PrintingDialog getPrinterInfo.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   368
    printerInfo isNil ifTrue:[^self].
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   369
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   370
    printer := self fromPrinterInfo: printerInfo.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   371
    [ 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   372
        printer startPrintJob: 'Strings with Position'.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   373
        printer foreground:Color black background:Color white.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   374
        stringAndPositionsArray
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   375
            do:[:pairOfPointsAndPosition |                 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   376
                 printer displayString:(pairOfPointsAndPosition at: 1) 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   377
                            x:(pairOfPointsAndPosition at: 2) x
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   378
                            y:(pairOfPointsAndPosition at: 2) y
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   379
            ].
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   380
        printer endPrintJob.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   381
    ] forkAt: 3
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   382
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   383
    "
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   384
     PrinterContext printStrings:  
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   385
        (Array with: (Array with:'Testing printing with standart method' with:10@10)
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   386
               with: (Array with:'Another test string to print' with:80@200))
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   387
    "
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   388
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   389
    "Created: / 07-08-2006 / 12:09:48 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   390
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
   391
    "Modified: / 10-10-2006 / 17:40:07 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   392
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   393
8f5996be6907 initial checkin
fm
parents:
diff changeset
   394
!PrinterContext methodsFor:'abort handling'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   395
8f5996be6907 initial checkin
fm
parents:
diff changeset
   396
abortPrintJob
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   397
    "Abort the current print job."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   398
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   399
    abort := true.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   400
    jobid := nil.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   401
8f5996be6907 initial checkin
fm
parents:
diff changeset
   402
    "Modified: / 02-08-2006 / 15:40:26 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   403
    "Modified: / 10-10-2006 / 18:13:45 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   404
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   405
8f5996be6907 initial checkin
fm
parents:
diff changeset
   406
aborted
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   407
    "Answer whether the user aborted from PrintAbortDialog."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   408
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   409
    ^ abort
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   410
8f5996be6907 initial checkin
fm
parents:
diff changeset
   411
    "Created: / 27-07-2006 / 10:20:10 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   412
    "Modified: / 10-10-2006 / 18:13:50 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   413
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   414
8f5996be6907 initial checkin
fm
parents:
diff changeset
   415
!PrinterContext methodsFor:'accessing'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   416
8f5996be6907 initial checkin
fm
parents:
diff changeset
   417
getCharHeight
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   418
    "Private - answer the height of the font selected in the receiver's
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   419
     device context."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   420
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   421
    |textMetrics|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   422
8f5996be6907 initial checkin
fm
parents:
diff changeset
   423
    textMetrics := Win32OperatingSystem::TextMetricsStructure new.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   424
    (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   425
    ^ textMetrics tmHeight + textMetrics tmExternalLeading
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   426
8f5996be6907 initial checkin
fm
parents:
diff changeset
   427
    "Created: / 02-08-2006 / 17:47:20 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   428
    "Modified: / 03-08-2006 / 10:09:01 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   429
    "Modified: / 10-10-2006 / 18:15:17 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   430
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   431
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   432
name
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   433
    "Answer the receiver's name from the current printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   434
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   435
    ^ self printerInfo printerName
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   436
8f5996be6907 initial checkin
fm
parents:
diff changeset
   437
    "Modified: / 02-08-2006 / 16:55:03 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   438
    "Modified: / 10-10-2006 / 18:15:33 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   439
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   440
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   441
name:aName 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   442
    "Set the receiver's printer name to aName."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   443
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   444
    self printerInfo:(self class getPrinterInformation:aName)
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   445
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   446
    "Modified: / 10-10-2006 / 18:15:36 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   447
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   448
8f5996be6907 initial checkin
fm
parents:
diff changeset
   449
numberOfColorBitsPerPixel
8f5996be6907 initial checkin
fm
parents:
diff changeset
   450
    ^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   451
8f5996be6907 initial checkin
fm
parents:
diff changeset
   452
    "Created: / 03-08-2006 / 09:58:18 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   453
    "Modified: / 10-10-2006 / 18:15:40 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   454
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   455
8f5996be6907 initial checkin
fm
parents:
diff changeset
   456
pixelsPerInchOfScreenHeight
8f5996be6907 initial checkin
fm
parents:
diff changeset
   457
    ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   458
8f5996be6907 initial checkin
fm
parents:
diff changeset
   459
    "Created: / 01-08-2006 / 16:29:16 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   460
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   461
8f5996be6907 initial checkin
fm
parents:
diff changeset
   462
pixelsPerInchOfScreenWidth
8f5996be6907 initial checkin
fm
parents:
diff changeset
   463
    ^ OperatingSystem getDeviceCaps:gcId index:88 "Logpixelsx"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   464
8f5996be6907 initial checkin
fm
parents:
diff changeset
   465
    "Created: / 01-08-2006 / 16:28:34 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   466
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   467
8f5996be6907 initial checkin
fm
parents:
diff changeset
   468
printerInfo
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   469
    "Answer the receiver's name from the current printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   470
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   471
    ^ printerInfo
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   472
8f5996be6907 initial checkin
fm
parents:
diff changeset
   473
    "Created: / 02-08-2006 / 16:55:17 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   474
    "Modified: / 10-10-2006 / 18:18:34 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   475
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   476
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   477
printerInfo:aPrinterInfo 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   478
    "Sets the receiver's printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   479
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   480
    printerInfo := aPrinterInfo
8f5996be6907 initial checkin
fm
parents:
diff changeset
   481
8f5996be6907 initial checkin
fm
parents:
diff changeset
   482
    "Created: / 02-08-2006 / 16:55:34 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   483
    "Modified: / 03-08-2006 / 13:11:19 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   484
    "Modified: / 10-10-2006 / 18:18:37 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   485
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   486
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   487
printerInfoWithName:aName 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   488
    "Set the receiver's printer name to aName."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   489
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   490
    self printerInfo:(self class getPrinterInformation:aName).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   491
    ^ self
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   492
8f5996be6907 initial checkin
fm
parents:
diff changeset
   493
    "Created: / 02-08-2006 / 16:55:52 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   494
    "Modified: / 10-10-2006 / 18:18:41 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   495
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   496
8f5996be6907 initial checkin
fm
parents:
diff changeset
   497
printerUserFriendlyName
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   498
    "Answer the receiver's name from the current printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   499
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   500
    ^ self printerInfo userFriendlyName
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   501
8f5996be6907 initial checkin
fm
parents:
diff changeset
   502
    "Created: / 03-08-2006 / 12:55:57 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   503
    "Modified: / 10-10-2006 / 18:18:55 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   504
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   505
8f5996be6907 initial checkin
fm
parents:
diff changeset
   506
!PrinterContext methodsFor:'initialization & release'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   507
8f5996be6907 initial checkin
fm
parents:
diff changeset
   508
buildPrinter
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   509
    "Private - create all the operating system resources needed."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   510
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   511
    self
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   512
        createDC;
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   513
        initExtent
8f5996be6907 initial checkin
fm
parents:
diff changeset
   514
8f5996be6907 initial checkin
fm
parents:
diff changeset
   515
    "Created: / 27-07-2006 / 10:20:36 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   516
    "Modified: / 01-08-2006 / 15:57:49 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   517
    "Modified: / 10-10-2006 / 18:14:04 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   518
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   519
8f5996be6907 initial checkin
fm
parents:
diff changeset
   520
createDC
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   521
    "Private - Create a device context for the receiver"
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   522
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   523
    gcId := printerInfo createDC
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   524
8f5996be6907 initial checkin
fm
parents:
diff changeset
   525
    "Created: / 27-07-2006 / 10:21:05 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   526
    "Modified: / 02-08-2006 / 17:30:47 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   527
    "Modified: / 10-10-2006 / 18:14:28 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   528
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   529
8f5996be6907 initial checkin
fm
parents:
diff changeset
   530
initExtent
8f5996be6907 initial checkin
fm
parents:
diff changeset
   531
    "Private - init the width and height of GraphicsTool for the receiver."
8f5996be6907 initial checkin
fm
parents:
diff changeset
   532
    
8f5996be6907 initial checkin
fm
parents:
diff changeset
   533
    device
8f5996be6907 initial checkin
fm
parents:
diff changeset
   534
        width:self printerWidthArea;
8f5996be6907 initial checkin
fm
parents:
diff changeset
   535
        height:self printerHeightArea
8f5996be6907 initial checkin
fm
parents:
diff changeset
   536
8f5996be6907 initial checkin
fm
parents:
diff changeset
   537
    "Modified: / 01-08-2006 / 16:14:49 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   538
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   539
8f5996be6907 initial checkin
fm
parents:
diff changeset
   540
printerHeightArea
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   541
    ^ (OperatingSystem getDeviceCaps:gcId index:10)
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   542
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   543
    "Modified: / 10-10-2006 / 18:18:31 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   544
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   545
8f5996be6907 initial checkin
fm
parents:
diff changeset
   546
printerWidthArea
8f5996be6907 initial checkin
fm
parents:
diff changeset
   547
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   548
8f5996be6907 initial checkin
fm
parents:
diff changeset
   549
    "Created: / 01-08-2006 / 16:14:08 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   550
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   551
8f5996be6907 initial checkin
fm
parents:
diff changeset
   552
!PrinterContext methodsFor:'printing'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   553
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   554
print:aString font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   555
    "Answer the receiver.  Output the receiver string to
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   556
     the printer using aFont.  A Print abort dialog box will be opened
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   557
     with aTitle.  If collateBoolean is true, collate output, otherwise
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   558
     do not.  Print copiesInteger copies of the specified string.  If
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   559
     wordWrapBoolean is true, word wrap the lines, otherwise do not.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   560
     Left, top, right & bottom margins are specified in inches in
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   561
     aMarginsRect."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   562
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   563
    |lines linesPerPage totalPage marginsRect firstPage charHeight abortDialog|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   564
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   565
    jobid isNil ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   566
        self startPrintJob:aTitle
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   567
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   568
    abortDialog := PrintAbortDialog new open:aTitle printer:self.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   569
    self font:aFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   570
    marginsRect := self marginsRectangleFor:aMarginsRect.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   571
    lines := self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   572
                asArrayOfStringLines:aString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   573
                in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   574
                wordWrap:wordWrapBoolean.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   575
    charHeight := self getCharHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   576
    linesPerPage := (marginsRect bottom - marginsRect top) // charHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   577
    totalPage := (lines size + linesPerPage - 1) // linesPerPage.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   578
    firstPage := true.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   579
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   580
"/    collateBoolean
8f5996be6907 initial checkin
fm
parents:
diff changeset
   581
"/        ifTrue: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   582
"/            copiesInteger timesRepeat: [
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   583
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   584
    1 to:totalPage do:[:page | 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   585
        abort ifTrue:[ ^ self ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   586
        firstPage ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   587
            self formFeed
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   588
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   589
        abortDialog 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   590
            updatePrintingPageInfo:(self class classResources
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   591
                                    string:'Page %1/%2'
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   592
                                    with:page printString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   593
                                    with:totalPage printString).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   594
        
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   595
"/      self device font: printerFont.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   596
        
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   597
        self font:aFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   598
        self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   599
            printPage:page
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   600
            in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   601
            lines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   602
            linesPerPage:linesPerPage.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   603
        firstPage := false
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   604
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   605
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   606
"/            ] 
8f5996be6907 initial checkin
fm
parents:
diff changeset
   607
"/        ] ifFalse: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   608
"/            1 to: totalPage do: [ :page |
8f5996be6907 initial checkin
fm
parents:
diff changeset
   609
"/                copiesInteger timesRepeat: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   610
"/                    abort ifTrue: [ ^self endPrintJob ].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   611
"/                    firstPage ifFalse: [ self formFeed ].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   612
"/                    self device font: printerFont.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   613
"/                    self printPage: page in: marginsRect lines: lines linesPerPage: linesPerPage.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   614
"/                    firstPage := false 
8f5996be6907 initial checkin
fm
parents:
diff changeset
   615
"/                 ] 
8f5996be6907 initial checkin
fm
parents:
diff changeset
   616
"/            ]   
8f5996be6907 initial checkin
fm
parents:
diff changeset
   617
"/        ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   618
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   619
    jobid notNil ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   620
        self endPrintJob.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   621
        abortDialog close.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   622
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   623
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   624
    "/    abort ifFalse: [ abortDialog close ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   625
8f5996be6907 initial checkin
fm
parents:
diff changeset
   626
    "Created: / 03-08-2006 / 16:13:33 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   627
    "Modified: / 04-08-2006 / 13:40:02 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   628
    "Modified: / 10-10-2006 / 18:16:54 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   629
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   630
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   631
print:aString pageHeader:aString2 font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   632
    "Private - Answer the receiver.  Output the receiver string to
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   633
     the printer using aFont.  A Print abort dialog box will be opened
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   634
     with aTitle.  If collateBoolean is true, collate output, otherwise
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   635
     do not.  Print copiesInteger copies of the specified string.  If
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   636
     wordWrapBoolean is true, word wrap the lines, otherwise do not.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   637
     Left, top, right & bottom margins are specified in inches in
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   638
     aMarginsRect."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   639
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   640
    |lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   641
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   642
    self font:aFont.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   643
    charHeight := self getCharHeight.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   644
    marginsRect := self marginsRectangleFor:aMarginsRect.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   645
    lines := self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   646
                asArrayOfStringLines:aString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   647
                in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   648
                wordWrap:wordWrapBoolean.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   649
    headerLines := self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   650
                asArrayOfStringLines:aString2
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   651
                in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   652
                wordWrap:wordWrapBoolean.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   653
    linesPerPage := (marginsRect bottom - marginsRect top) // charHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   654
    linesPerPage > headerLines size ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   655
        Dialog information:(self class classResources 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   656
                                string:'The header is too large - ignored!!').
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   657
        headerLines := #().
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   658
    ] ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   659
        linesPerPage := linesPerPage - headerLines size
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   660
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   661
    totalPage := (lines size + linesPerPage - 1) // linesPerPage.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   662
    firstPage := true.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   663
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   664
"/    collateBoolean
8f5996be6907 initial checkin
fm
parents:
diff changeset
   665
"/        ifTrue: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   666
"/            copiesInteger timesRepeat: [
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   667
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   668
    1 to:totalPage do:[:page | 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   669
        abort ifTrue:[ ^ self ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   670
        firstPage ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   671
            self formFeed
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   672
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   673
        self font:printerFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   674
        self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   675
            printPage:page
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   676
            in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   677
            lines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   678
            headerLines:headerLines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   679
            linesPerPage:linesPerPage.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   680
        firstPage := false
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   681
    ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   682
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   683
    "/            ] 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   684
    "/        ] ifFalse: [
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   685
    "/            1 to: totalPage do: [ :page |
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   686
    "/                copiesInteger timesRepeat: [
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   687
    "/                    abort ifTrue: [ ^self endPrintJob ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   688
    "/                    firstPage ifFalse: [ self formFeed ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   689
    "/                    self device font: printerFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   690
    "/                    self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   691
    "/                    firstPage := false 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   692
    "/                ] 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   693
    "/            ] 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   694
    "/        ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   695
8f5996be6907 initial checkin
fm
parents:
diff changeset
   696
    "Created: / 03-08-2006 / 16:14:10 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   697
    "Modified: / 10-10-2006 / 18:18:03 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   698
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   699
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   700
!PrinterContext methodsFor:'printing process'!
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   701
8f5996be6907 initial checkin
fm
parents:
diff changeset
   702
endPage
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   703
    "Informs device that we are finished writing to a page."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   704
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   705
    (OperatingSystem endPage:gcId) > 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   706
        self error
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   707
    ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   708
8f5996be6907 initial checkin
fm
parents:
diff changeset
   709
    "Created: / 27-07-2006 / 18:20:48 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   710
    "Modified: / 01-08-2006 / 16:01:34 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   711
    "Modified: / 10-10-2006 / 18:14:44 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   712
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   713
8f5996be6907 initial checkin
fm
parents:
diff changeset
   714
endPrintJob
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   715
    "End the print job.  Everything drawn between startPrintJob
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   716
     and endPrintJob will become one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   717
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   718
    |result|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   719
8f5996be6907 initial checkin
fm
parents:
diff changeset
   720
    self endPage.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   721
    result := OperatingSystem endDoc:gcId.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   722
    device close.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   723
    gcId := nil.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   724
    jobid := nil.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   725
    result >= 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   726
        ^ self error
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   727
    ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   728
8f5996be6907 initial checkin
fm
parents:
diff changeset
   729
    "Created: / 27-07-2006 / 18:21:04 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   730
    "Modified: / 01-08-2006 / 16:01:38 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   731
    "Modified: / 10-10-2006 / 18:15:02 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   732
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   733
8f5996be6907 initial checkin
fm
parents:
diff changeset
   734
formFeed
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   735
    "Send a form feed to the printer."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   736
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   737
    self
8f5996be6907 initial checkin
fm
parents:
diff changeset
   738
        endPage;
8f5996be6907 initial checkin
fm
parents:
diff changeset
   739
        startPage
8f5996be6907 initial checkin
fm
parents:
diff changeset
   740
8f5996be6907 initial checkin
fm
parents:
diff changeset
   741
    "Created: / 27-07-2006 / 18:25:40 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   742
    "Modified: / 10-10-2006 / 18:15:07 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   743
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   744
8f5996be6907 initial checkin
fm
parents:
diff changeset
   745
startPage
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   746
    "Starts a page."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   747
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   748
    (OperatingSystem startPage:gcId) > 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   749
        ^ self error
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   750
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   751
8f5996be6907 initial checkin
fm
parents:
diff changeset
   752
    "Created: / 27-07-2006 / 18:25:55 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   753
    "Modified: / 28-07-2006 / 18:19:04 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   754
    "Modified: / 10-10-2006 / 18:19:02 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   755
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   756
8f5996be6907 initial checkin
fm
parents:
diff changeset
   757
startPrintJob
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   758
    "Start a print job.  Everything drawn between startPrintJob
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   759
     and endPrintJob will become one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   760
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   761
    self startPrintJob:nil
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   762
8f5996be6907 initial checkin
fm
parents:
diff changeset
   763
    "Created: / 27-07-2006 / 18:18:52 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   764
    "Modified: / 10-10-2006 / 18:19:05 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   765
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   766
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   767
startPrintJob:aString 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   768
    "Start a print job, using aString as the job title; everything
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   769
     drawn between startPrintJob and endPrintJob will become
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   770
     one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   771
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   772
    ^ self startPrintJob:aString fileName:nil
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   773
8f5996be6907 initial checkin
fm
parents:
diff changeset
   774
    "Created: / 27-07-2006 / 18:19:09 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   775
    "Modified: / 10-10-2006 / 18:19:12 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   776
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   777
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   778
startPrintJob:aString fileName:aFileName 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   779
    "Start a print job, using aString as the job title; everything
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   780
     drawn between startPrintJob and endPrintJob will become
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   781
     one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   782
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   783
    |docInfoStruct nameAddress title fileNameAddress|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   784
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   785
    gcId isNil ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   786
        self buildPrinter
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   787
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   788
    abort := false.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   789
    title := aString ? 'Smalltalk/X'.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   790
    nameAddress := title asExternalBytes unprotectFromGC.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   791
    aFileName isNil ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   792
        fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   793
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   794
    docInfoStruct := Win32OperatingSystem::DocInfoStructure new.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   795
    docInfoStruct
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   796
        cbSize:docInfoStruct sizeInBytes;
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   797
        lpszDocName:nameAddress address.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   798
    fileNameAddress isNil ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   799
        docInfoStruct lpszOutput:fileNameAddress address
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   800
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   801
    jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   802
    jobid > 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   803
        jobid = -1 ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   804
            abort := true.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   805
            ^ nil
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   806
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   807
        ^ self error
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   808
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   809
    self startPage
8f5996be6907 initial checkin
fm
parents:
diff changeset
   810
8f5996be6907 initial checkin
fm
parents:
diff changeset
   811
    "Created: / 27-07-2006 / 18:19:31 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   812
    "Modified: / 03-08-2006 / 15:11:19 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   813
    "Modified: / 10-10-2006 / 18:20:01 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   814
! !
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   815
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   816
!PrinterContext methodsFor:'queries'!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   817
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   818
supportsColor
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   819
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   820
"/    | retVal info |
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   821
"/
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   822
"/    info := (self class getPrinterInformation: self name) asUppercase.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   823
"/    (info includesSubstring: ',PSCRIPT,')
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   824
"/    ifTrue: [
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   825
"/        retVal := (DAPASX::DapasSystemInfo getYesNoInfoApp: 'Printer' profile: 'PostScriptBlackWhite') not.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   826
"/    ]
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   827
"/    ifFalse: [
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   828
"/        retVal := (info includesSubstring: 'PDF')
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   829
"/            ifTrue: [true]
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   830
"/            ifFalse: [self numberOfColorBitsPerPixel > 1].
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   831
"/    ].
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   832
"/
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   833
"/    ^retVal
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   834
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   835
    ^ false.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   836
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   837
    "Created: / 03-08-2006 / 09:55:26 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   838
    "Modified: / 04-08-2006 / 13:20:40 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   839
    "Modified: / 10-10-2006 / 18:21:07 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   840
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   841
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   842
supportsGraphics
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   843
    ^(OperatingSystem getDeviceCaps: gcId asParameter index: 2 "Technology") ~= 4
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   844
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   845
    "Created: / 03-08-2006 / 10:07:43 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   846
    "Modified: / 10-10-2006 / 18:21:14 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   847
! !
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   848
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   849
!PrinterContext methodsFor:'text printing'!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   850
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   851
asArrayOfStringLines:aString in:aRectangle wordWrap:wordWrapBoolean 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   852
    "Private - convert aString into an array of lines; if wordWrapBoolean
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   853
     is true, also perform word wrapping on the lines, within aRectangle."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   854
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   855
    |line lines stream x0 x1 partialLine leftMargin rightMargin partialLineWidth index|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   856
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   857
    stream := ReadStream on:aString.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   858
    lines := OrderedCollection new.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   859
    wordWrapBoolean ifTrue:[
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   860
        leftMargin := aRectangle left.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   861
        rightMargin := aRectangle right
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   862
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   863
    [ stream atEnd ] whileFalse:[
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   864
        line := stream nextLine.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   865
        wordWrapBoolean ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   866
            lines add:line
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   867
        ] ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   868
            x0 := x1 := 1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   869
            1 to:line size do:[:i | 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   870
                ((line at:i) = Character space "32" 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   871
                    and:[ (partialLine := line copyFrom:x0 to:i) trimBlanks notEmpty ]) 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   872
                        ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   873
                            partialLineWidth := self stringWidthOf:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   874
                            (leftMargin + partialLineWidth) > rightMargin ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   875
                                partialLine := line copyFrom:x0 to:x1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   876
                                lines add:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   877
                                x0 := x1 + 1
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   878
                            ] ifFalse:[ x1 := i ]
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   879
                        ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   880
                index := i
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   881
            ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   882
            line isEmpty ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   883
                lines add:line
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   884
            ] ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   885
                partialLine := line copyFrom:x0 to:index.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   886
                partialLineWidth := self stringWidthOf:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   887
                (leftMargin + partialLineWidth) > rightMargin ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   888
                    partialLine := line copyFrom:x0 to:x1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   889
                    lines add:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   890
                    partialLine := line copyFrom:x1 + 1 to:index
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   891
                ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   892
                lines add:partialLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   893
            ]
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   894
        ]
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   895
    ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   896
    ^ lines asArray
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   897
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   898
    "Created: / 02-08-2006 / 17:56:51 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   899
    "Modified: / 04-08-2006 / 13:39:50 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   900
    "Modified: / 10-10-2006 / 18:14:00 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   901
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   902
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   903
displayStringLines:anIndexedCollection from:startIndex to:endIndex in:aRectangle 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   904
    "Private - display Strings in anIndexedCollection starting at startIndex and
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   905
     ending at endIndex, clipped within the bounds of aRectangle."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   906
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   907
    |charHeight ta region ascent|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   908
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   909
    charHeight := self getCharHeight.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   910
    ascent := self font ascentOn:self device.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   911
    startIndex to:endIndex do:[:i | 
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   912
        |lineToPrint|
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   913
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   914
        lineToPrint := (anIndexedCollection at:i).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   915
        self device 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   916
            displayString:lineToPrint
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   917
            from:1
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   918
            to:lineToPrint size
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   919
            x:aRectangle left
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   920
            y:(aRectangle top + ((i - startIndex) * charHeight))
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   921
            in:nil
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   922
            with:gcId
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   923
            opaque:false
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   924
            fontAscent:ascent.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   925
    ].
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   926
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   927
    "/    region := self setClipRect: aRectangle.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   928
    "/    ta := self getTextAlign.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   929
    "/    self setTextAlign: TaTop.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   930
    "/    startIndex to: endIndex do: [ :i |
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   931
    "/        self
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   932
    "/            displayText: ( anIndexedCollection at: i )
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   933
    "/            at: aRectangle left @ ( aRectangle top + ( i - startIndex * charHeight ) ) ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   934
    "/    self setTextAlign: ta.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   935
    "/    self destroyRegion: region
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   936
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   937
    "Created: / 03-08-2006 / 11:37:52 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   938
    "Modified: / 03-08-2006 / 12:38:43 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   939
    "Modified: / 10-10-2006 / 18:14:36 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   940
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   941
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   942
displayStringLines:anIndexedCollection in:aRectangle 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   943
    "Private - display anIndexedCollection of Strings clipped within
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   944
     the bounds of aRectangle."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   945
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   946
    self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   947
        displayStringLines:anIndexedCollection
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   948
        from:1
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   949
        to:anIndexedCollection size
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   950
        in:aRectangle
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   951
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   952
    "Created: / 03-08-2006 / 16:03:07 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   953
    "Modified: / 10-10-2006 / 18:14:40 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   954
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   955
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   956
marginsRectangleFor:aRectangle 
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   957
    "Private - Answer a Rectangle defining margins based on aRectangle.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   958
     Units for aRectangle are in inches, returned margins rectangle is
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   959
     in device units (pixels)."
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   960
    
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   961
    |left top right bottom pixelsPerInchX pixelsPerInchY horzRes vertRes inset rectangle|
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   962
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   963
    pixelsPerInchX := self pixelsPerInchOfScreenWidth.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   964
    pixelsPerInchY := self pixelsPerInchOfScreenHeight.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   965
    aRectangle isNil ifTrue:[
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   966
        horzRes := self printerWidthArea.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   967
        vertRes := self printerHeightArea.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   968
        inset := self class defaultMargins.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   969
        left := (inset x * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   970
        top := (inset y * pixelsPerInchY) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   971
        right := horzRes - (inset x * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   972
        bottom := vertRes - (inset y * pixelsPerInchY) asInteger
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   973
    ] ifFalse:[
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   974
        left := (aRectangle left * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   975
        top := (aRectangle top * pixelsPerInchY) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   976
        right := (aRectangle right * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   977
        bottom := (aRectangle bottom * pixelsPerInchY) asInteger
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   978
    ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   979
    rectangle := left @ top extent:right @ bottom.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   980
    ^ rectangle
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   981
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   982
    "Created: / 27-07-2006 / 18:22:57 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   983
    "Modified: / 04-08-2006 / 13:39:45 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   984
    "Modified: / 10-10-2006 / 18:15:26 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   985
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   986
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   987
printPage:pageIndex in:aRectangle lines:lines headerLines:headerLines linesPerPage:linesPerPage 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   988
    "Private - print page # pageIndex from lines, assuming
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   989
     the given number of linesPerPage."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   990
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   991
    |firstLine lastLine l indexString p cHeight rect hLines|
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   992
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   993
    firstLine := (pageIndex - 1) * linesPerPage + 1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   994
    lastLine := (firstLine + linesPerPage - 1) min:lines size.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   995
    rect := aRectangle deepCopy.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   996
    hLines := headerLines deepCopy.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   997
    headerLines size > 0 ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   998
        l := hLines first.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   999
        (p := l indexOfString:'#P') = 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1000
            indexString := pageIndex printString , ' '.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1001
            l := (l copyFrom:1 to:p - 1) , indexString , (l copyFrom:p + 2 to:l size).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1002
            hLines at:1 put:l.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1003
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1004
        cHeight := self getCharHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1005
        rect top:rect top + (hLines size * cHeight).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1006
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1007
    self displayStringLines:hLines in:aRectangle.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1008
    self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1009
        displayStringLines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1010
        from:firstLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1011
        to:lastLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1012
        in:rect.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1013
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1014
    "Created: / 27-07-2006 / 18:28:00 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1015
    "Modified: / 03-08-2006 / 16:03:15 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1016
    "Modified: / 10-10-2006 / 18:18:15 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1017
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1018
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1019
printPage:pageIndex in:aRectangle lines:lines linesPerPage:linesPerPage 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1020
    "Private - print page # pageIndex from lines, assuming
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1021
     the given number of linesPerPage."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1022
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1023
    |firstLine lastLine|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1024
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1025
    firstLine := (pageIndex - 1) * linesPerPage + 1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1026
    lastLine := (firstLine + linesPerPage - 1) min:lines size.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1027
    self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1028
        displayStringLines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1029
        from:firstLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1030
        to:lastLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1031
        in:aRectangle
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1032
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1033
    "Created: / 27-07-2006 / 18:24:59 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1034
    "Modified: / 03-08-2006 / 12:47:24 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1035
    "Modified: / 10-10-2006 / 18:18:22 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1036
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1037
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1038
stringWidthOf:aString 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1039
    "Return the width of aString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1040
     when written using the current font."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1041
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1042
    ^ self stringWidthOf:aString at:aString size.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1043
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1044
    "Modified: / 03-08-2006 / 10:18:23 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1045
    "Modified: / 10-10-2006 / 18:20:08 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1046
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1047
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1048
stringWidthOf:aString at:index 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1049
    "Return the width of aString up to index
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1050
     when written using the current font; expand tabs out
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1051
     to 4 spaces for calculations"
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1052
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1053
    |answer str size spaceWidth|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1054
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1055
    index <= 0 ifTrue:[ ^ 0 ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1056
    str := index >= aString size ifTrue:[ aString ] ifFalse:[ aString copyFrom:1 to:index ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1057
    true "self font isNil" ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1058
        "if font not set yet, calculate based on default font"
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1059
        "/            extString := str asExternalString.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1060
        size := Win32OperatingSystem::WinPointStructure new.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1061
        (OperatingSystem 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1062
            getTextExtentPoint:gcId
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1063
            string:str
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1064
            size:size) ifFalse:[ ^ self error ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1065
        answer := size x.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1066
        #TODO.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1067
    ] ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1068
        answer := self font widthOf:str on:self device
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1069
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1070
    index > aString size ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1071
        spaceWidth := self font widthOf:Character space on:self device.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1072
        answer := answer + ((index - aString size) * spaceWidth)
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1073
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1074
    ^ answer.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1075
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1076
    "Created: / 03-08-2006 / 10:27:20 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1077
    "Modified: / 04-08-2006 / 12:27:26 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1078
    "Modified: / 10-10-2006 / 18:20:43 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1079
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1080
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1081
!PrinterContext class methodsFor:'documentation'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1082
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1083
version
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1084
    ^ '$Header: /cvs/stx/stx/libview2/PrinterContext.st,v 1.6 2006-10-10 16:22:07 cg Exp $'
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1085
! !