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