PrinterContext.st
author Claus Gittinger <cg@exept.de>
Tue, 10 Oct 2006 20:25:51 +0200
changeset 2237 950fb103a14e
parent 2236 76291d984db9
child 2247 b0a3ddb53d25
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2184
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     1
"
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     3
              All Rights Reserved
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     4
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     5
 This software is furnished under a license and may be used
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     6
 only in accordance with the terms of that license and with the
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
     9
 other person.  No title to or ownership of the software is
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    10
 hereby transferred.
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    11
"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    12
"{ Package: 'stx:libview2' }"
8f5996be6907 initial checkin
fm
parents:
diff changeset
    13
8f5996be6907 initial checkin
fm
parents:
diff changeset
    14
GraphicsMedium subclass:#PrinterContext
8f5996be6907 initial checkin
fm
parents:
diff changeset
    15
	instanceVariableNames:'name abort jobid printerInfo'
8f5996be6907 initial checkin
fm
parents:
diff changeset
    16
	classVariableNames:''
8f5996be6907 initial checkin
fm
parents:
diff changeset
    17
	poolDictionaries:''
8f5996be6907 initial checkin
fm
parents:
diff changeset
    18
	category:'Interface-Printing'
8f5996be6907 initial checkin
fm
parents:
diff changeset
    19
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
    20
2184
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    21
!PrinterContext class methodsFor:'documentation'!
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    22
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    23
copyright
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    24
"
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    25
 COPYRIGHT (c) 2006 by eXept Software AG
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    26
              All Rights Reserved
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    27
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    28
 This software is furnished under a license and may be used
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    29
 only in accordance with the terms of that license and with the
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    31
 be provided or otherwise made available to, or used by, any
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    32
 other person.  No title to or ownership of the software is
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    33
 hereby transferred.
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    34
"
2235
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    35
!
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    36
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    37
documentation
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    38
"
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    39
    I am the mediator between the smalltalk printing protocol 
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    40
    (which is the same as the graphics drawing protocol) and the
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    41
    windows printer.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    42
    When youopena printer, you will typically talk to me, and I will
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    43
    forward the graphics commands to my printer.
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    44
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    45
    [author:]
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    46
        Felix Madrid (fm@exept.de)
0df6bda4b353 pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents: 2184
diff changeset
    47
"
2184
c108f1291023 copyright methods
Claus Gittinger <cg@exept.de>
parents: 2147
diff changeset
    48
! !
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
    49
8f5996be6907 initial checkin
fm
parents:
diff changeset
    50
!PrinterContext class methodsFor:'instance creation'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
    51
8f5996be6907 initial checkin
fm
parents:
diff changeset
    52
fromPrinterInfo: aPrinterInfo
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
8f5996be6907 initial checkin
fm
parents:
diff changeset
   411
getCharHeight
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   412
    "Private - answer the height of the font selected in the receiver's
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   413
     device context."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   414
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   415
    |textMetrics|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   416
8f5996be6907 initial checkin
fm
parents:
diff changeset
   417
    textMetrics := Win32OperatingSystem::TextMetricsStructure new.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   418
    (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   419
    ^ textMetrics tmHeight + textMetrics tmExternalLeading
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   420
8f5996be6907 initial checkin
fm
parents:
diff changeset
   421
    "Created: / 02-08-2006 / 17:47:20 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   422
    "Modified: / 03-08-2006 / 10:09:01 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   423
    "Modified: / 10-10-2006 / 18:15:17 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   424
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   425
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   426
name
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   427
    "Answer the receiver's name from the current printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   428
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   429
    ^ self printerInfo printerName
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   430
8f5996be6907 initial checkin
fm
parents:
diff changeset
   431
    "Modified: / 02-08-2006 / 16:55:03 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   432
    "Modified: / 10-10-2006 / 18:15:33 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   433
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   434
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   435
name:aName 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   436
    "Set the receiver's printer name to aName."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   437
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   438
    self printerInfo:(self class getPrinterInformation:aName)
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   439
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   440
    "Modified: / 10-10-2006 / 18:15:36 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   441
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   442
8f5996be6907 initial checkin
fm
parents:
diff changeset
   443
numberOfColorBitsPerPixel
8f5996be6907 initial checkin
fm
parents:
diff changeset
   444
    ^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   445
8f5996be6907 initial checkin
fm
parents:
diff changeset
   446
    "Created: / 03-08-2006 / 09:58:18 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   447
    "Modified: / 10-10-2006 / 18:15:40 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   448
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   449
8f5996be6907 initial checkin
fm
parents:
diff changeset
   450
pixelsPerInchOfScreenHeight
8f5996be6907 initial checkin
fm
parents:
diff changeset
   451
    ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   452
8f5996be6907 initial checkin
fm
parents:
diff changeset
   453
    "Created: / 01-08-2006 / 16:29:16 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   454
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   455
8f5996be6907 initial checkin
fm
parents:
diff changeset
   456
pixelsPerInchOfScreenWidth
8f5996be6907 initial checkin
fm
parents:
diff changeset
   457
    ^ OperatingSystem getDeviceCaps:gcId index:88 "Logpixelsx"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   458
8f5996be6907 initial checkin
fm
parents:
diff changeset
   459
    "Created: / 01-08-2006 / 16:28:34 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   460
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   461
8f5996be6907 initial checkin
fm
parents:
diff changeset
   462
printerInfo
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   463
    "Answer the receiver's name from the current printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   464
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   465
    ^ printerInfo
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   466
8f5996be6907 initial checkin
fm
parents:
diff changeset
   467
    "Created: / 02-08-2006 / 16:55:17 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   468
    "Modified: / 10-10-2006 / 18:18:34 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   469
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   470
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   471
printerInfo:aPrinterInfo 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   472
    "Sets the receiver's printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   473
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   474
    printerInfo := aPrinterInfo
8f5996be6907 initial checkin
fm
parents:
diff changeset
   475
8f5996be6907 initial checkin
fm
parents:
diff changeset
   476
    "Created: / 02-08-2006 / 16:55:34 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   477
    "Modified: / 03-08-2006 / 13:11:19 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   478
    "Modified: / 10-10-2006 / 18:18:37 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   479
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   480
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   481
printerInfoWithName:aName 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   482
    "Set the receiver's printer name to aName."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   483
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   484
    self printerInfo:(self class getPrinterInformation:aName).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   485
    ^ self
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   486
8f5996be6907 initial checkin
fm
parents:
diff changeset
   487
    "Created: / 02-08-2006 / 16:55:52 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   488
    "Modified: / 10-10-2006 / 18:18:41 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   489
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   490
8f5996be6907 initial checkin
fm
parents:
diff changeset
   491
printerUserFriendlyName
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   492
    "Answer the receiver's name from the current printerInfo."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   493
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   494
    ^ self printerInfo userFriendlyName
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   495
8f5996be6907 initial checkin
fm
parents:
diff changeset
   496
    "Created: / 03-08-2006 / 12:55:57 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   497
    "Modified: / 10-10-2006 / 18:18:55 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   498
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   499
8f5996be6907 initial checkin
fm
parents:
diff changeset
   500
!PrinterContext methodsFor:'initialization & release'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   501
8f5996be6907 initial checkin
fm
parents:
diff changeset
   502
buildPrinter
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   503
    "Private - create all the operating system resources needed."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   504
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   505
    self
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   506
        createDC;
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   507
        initExtent
8f5996be6907 initial checkin
fm
parents:
diff changeset
   508
8f5996be6907 initial checkin
fm
parents:
diff changeset
   509
    "Created: / 27-07-2006 / 10:20:36 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   510
    "Modified: / 01-08-2006 / 15:57:49 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   511
    "Modified: / 10-10-2006 / 18:14:04 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   512
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   513
8f5996be6907 initial checkin
fm
parents:
diff changeset
   514
createDC
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   515
    "Private - Create a device context for the receiver"
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   516
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   517
    gcId := printerInfo createDC
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   518
8f5996be6907 initial checkin
fm
parents:
diff changeset
   519
    "Created: / 27-07-2006 / 10:21:05 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   520
    "Modified: / 02-08-2006 / 17:30:47 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   521
    "Modified: / 10-10-2006 / 18:14:28 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   522
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   523
8f5996be6907 initial checkin
fm
parents:
diff changeset
   524
initExtent
8f5996be6907 initial checkin
fm
parents:
diff changeset
   525
    "Private - init the width and height of GraphicsTool for the receiver."
8f5996be6907 initial checkin
fm
parents:
diff changeset
   526
    
8f5996be6907 initial checkin
fm
parents:
diff changeset
   527
    device
8f5996be6907 initial checkin
fm
parents:
diff changeset
   528
        width:self printerWidthArea;
8f5996be6907 initial checkin
fm
parents:
diff changeset
   529
        height:self printerHeightArea
8f5996be6907 initial checkin
fm
parents:
diff changeset
   530
8f5996be6907 initial checkin
fm
parents:
diff changeset
   531
    "Modified: / 01-08-2006 / 16:14:49 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   532
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   533
8f5996be6907 initial checkin
fm
parents:
diff changeset
   534
printerHeightArea
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   535
    ^ (OperatingSystem getDeviceCaps:gcId index:10)
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   536
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   537
    "Modified: / 10-10-2006 / 18:18:31 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   538
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   539
8f5996be6907 initial checkin
fm
parents:
diff changeset
   540
printerWidthArea
8f5996be6907 initial checkin
fm
parents:
diff changeset
   541
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   542
8f5996be6907 initial checkin
fm
parents:
diff changeset
   543
    "Created: / 01-08-2006 / 16:14:08 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   544
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   545
8f5996be6907 initial checkin
fm
parents:
diff changeset
   546
!PrinterContext methodsFor:'printing'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   547
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   548
print:aString font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   549
    "Answer the receiver.  Output the receiver string to
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   550
     the printer using aFont.  A Print abort dialog box will be opened
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   551
     with aTitle.  If collateBoolean is true, collate output, otherwise
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   552
     do not.  Print copiesInteger copies of the specified string.  If
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   553
     wordWrapBoolean is true, word wrap the lines, otherwise do not.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   554
     Left, top, right & bottom margins are specified in inches in
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   555
     aMarginsRect."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   556
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   557
    |lines linesPerPage totalPage marginsRect firstPage charHeight abortDialog|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   558
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   559
    jobid isNil ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   560
        self startPrintJob:aTitle
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   561
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   562
    abortDialog := PrintAbortDialog new open:aTitle printer:self.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   563
    self font:aFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   564
    marginsRect := self marginsRectangleFor:aMarginsRect.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   565
    lines := self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   566
                asArrayOfStringLines:aString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   567
                in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   568
                wordWrap:wordWrapBoolean.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   569
    charHeight := self getCharHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   570
    linesPerPage := (marginsRect bottom - marginsRect top) // charHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   571
    totalPage := (lines size + linesPerPage - 1) // linesPerPage.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   572
    firstPage := true.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   573
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   574
"/    collateBoolean
8f5996be6907 initial checkin
fm
parents:
diff changeset
   575
"/        ifTrue: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   576
"/            copiesInteger timesRepeat: [
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   577
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   578
    1 to:totalPage do:[:page | 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   579
        abort ifTrue:[ ^ self ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   580
        firstPage ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   581
            self formFeed
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   582
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   583
        abortDialog 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   584
            updatePrintingPageInfo:(self class classResources
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   585
                                    string:'Page %1/%2'
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   586
                                    with:page printString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   587
                                    with:totalPage printString).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   588
        
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   589
"/      self device font: printerFont.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   590
        
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   591
        self font:aFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   592
        self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   593
            printPage:page
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   594
            in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   595
            lines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   596
            linesPerPage:linesPerPage.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   597
        firstPage := false
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   598
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   599
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   600
"/            ] 
8f5996be6907 initial checkin
fm
parents:
diff changeset
   601
"/        ] ifFalse: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   602
"/            1 to: totalPage do: [ :page |
8f5996be6907 initial checkin
fm
parents:
diff changeset
   603
"/                copiesInteger timesRepeat: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   604
"/                    abort ifTrue: [ ^self endPrintJob ].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   605
"/                    firstPage ifFalse: [ self formFeed ].
8f5996be6907 initial checkin
fm
parents:
diff changeset
   606
"/                    self device font: printerFont.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   607
"/                    self printPage: page in: marginsRect lines: lines linesPerPage: linesPerPage.
8f5996be6907 initial checkin
fm
parents:
diff changeset
   608
"/                    firstPage := false 
8f5996be6907 initial checkin
fm
parents:
diff changeset
   609
"/                 ] 
8f5996be6907 initial checkin
fm
parents:
diff changeset
   610
"/            ]   
8f5996be6907 initial checkin
fm
parents:
diff changeset
   611
"/        ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   612
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   613
    jobid notNil ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   614
        self endPrintJob.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   615
        abortDialog close.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   616
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   617
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   618
    "/    abort ifFalse: [ abortDialog close ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   619
8f5996be6907 initial checkin
fm
parents:
diff changeset
   620
    "Created: / 03-08-2006 / 16:13:33 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   621
    "Modified: / 04-08-2006 / 13:40:02 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   622
    "Modified: / 10-10-2006 / 18:16:54 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   623
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   624
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   625
print:aString pageHeader:aString2 font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   626
    "Private - Answer the receiver.  Output the receiver string to
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   627
     the printer using aFont.  A Print abort dialog box will be opened
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   628
     with aTitle.  If collateBoolean is true, collate output, otherwise
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   629
     do not.  Print copiesInteger copies of the specified string.  If
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   630
     wordWrapBoolean is true, word wrap the lines, otherwise do not.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   631
     Left, top, right & bottom margins are specified in inches in
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   632
     aMarginsRect."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   633
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   634
    |lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   635
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   636
    self font:aFont.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   637
    charHeight := self getCharHeight.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   638
    marginsRect := self marginsRectangleFor:aMarginsRect.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   639
    lines := self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   640
                asArrayOfStringLines:aString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   641
                in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   642
                wordWrap:wordWrapBoolean.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   643
    headerLines := self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   644
                asArrayOfStringLines:aString2
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   645
                in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   646
                wordWrap:wordWrapBoolean.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   647
    linesPerPage := (marginsRect bottom - marginsRect top) // charHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   648
    linesPerPage > headerLines size ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   649
        Dialog information:(self class classResources 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   650
                                string:'The header is too large - ignored!!').
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   651
        headerLines := #().
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   652
    ] ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   653
        linesPerPage := linesPerPage - headerLines size
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   654
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   655
    totalPage := (lines size + linesPerPage - 1) // linesPerPage.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   656
    firstPage := true.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   657
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   658
"/    collateBoolean
8f5996be6907 initial checkin
fm
parents:
diff changeset
   659
"/        ifTrue: [
8f5996be6907 initial checkin
fm
parents:
diff changeset
   660
"/            copiesInteger timesRepeat: [
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   661
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   662
    1 to:totalPage do:[:page | 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   663
        abort ifTrue:[ ^ self ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   664
        firstPage ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   665
            self formFeed
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   666
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   667
        self font:printerFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   668
        self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   669
            printPage:page
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   670
            in:marginsRect
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   671
            lines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   672
            headerLines:headerLines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   673
            linesPerPage:linesPerPage.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   674
        firstPage := false
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   675
    ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   676
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   677
    "/            ] 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   678
    "/        ] ifFalse: [
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   679
    "/            1 to: totalPage do: [ :page |
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   680
    "/                copiesInteger timesRepeat: [
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   681
    "/                    abort ifTrue: [ ^self endPrintJob ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   682
    "/                    firstPage ifFalse: [ self formFeed ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   683
    "/                    self device font: printerFont.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   684
    "/                    self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   685
    "/                    firstPage := false 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   686
    "/                ] 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   687
    "/            ] 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   688
    "/        ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   689
8f5996be6907 initial checkin
fm
parents:
diff changeset
   690
    "Created: / 03-08-2006 / 16:14:10 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   691
    "Modified: / 10-10-2006 / 18:18:03 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   692
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
   693
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   694
!PrinterContext methodsFor:'printing process'!
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   695
8f5996be6907 initial checkin
fm
parents:
diff changeset
   696
endPage
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   697
    "Informs device that we are finished writing to a page."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   698
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   699
    (OperatingSystem endPage:gcId) > 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   700
        self error
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   701
    ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   702
8f5996be6907 initial checkin
fm
parents:
diff changeset
   703
    "Created: / 27-07-2006 / 18:20:48 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   704
    "Modified: / 01-08-2006 / 16:01:34 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   705
    "Modified: / 10-10-2006 / 18:14:44 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   706
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   707
8f5996be6907 initial checkin
fm
parents:
diff changeset
   708
endPrintJob
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   709
    "End the print job.  Everything drawn between startPrintJob
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   710
     and endPrintJob will become one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   711
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   712
    |result|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   713
8f5996be6907 initial checkin
fm
parents:
diff changeset
   714
    self endPage.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   715
    result := OperatingSystem endDoc:gcId.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   716
    device close.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   717
    gcId := nil.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   718
    jobid := nil.
2237
950fb103a14e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   719
    result >= 0 ifFalse:[ self error ]
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   720
8f5996be6907 initial checkin
fm
parents:
diff changeset
   721
    "Created: / 27-07-2006 / 18:21:04 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   722
    "Modified: / 01-08-2006 / 16:01:38 / fm"
2237
950fb103a14e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
   723
    "Modified: / 10-10-2006 / 18:50:43 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   724
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   725
8f5996be6907 initial checkin
fm
parents:
diff changeset
   726
formFeed
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   727
    "Send a form feed to the printer."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   728
    
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   729
    self
8f5996be6907 initial checkin
fm
parents:
diff changeset
   730
        endPage;
8f5996be6907 initial checkin
fm
parents:
diff changeset
   731
        startPage
8f5996be6907 initial checkin
fm
parents:
diff changeset
   732
8f5996be6907 initial checkin
fm
parents:
diff changeset
   733
    "Created: / 27-07-2006 / 18:25:40 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   734
    "Modified: / 10-10-2006 / 18:15:07 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   735
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   736
8f5996be6907 initial checkin
fm
parents:
diff changeset
   737
startPage
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   738
    "Starts a page."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   739
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   740
    (OperatingSystem startPage:gcId) > 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   741
        ^ self error
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   742
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   743
8f5996be6907 initial checkin
fm
parents:
diff changeset
   744
    "Created: / 27-07-2006 / 18:25:55 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   745
    "Modified: / 28-07-2006 / 18:19:04 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   746
    "Modified: / 10-10-2006 / 18:19:02 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   747
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   748
8f5996be6907 initial checkin
fm
parents:
diff changeset
   749
startPrintJob
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   750
    "Start a print job.  Everything drawn between startPrintJob
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   751
     and endPrintJob will become one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   752
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   753
    self startPrintJob:nil
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   754
8f5996be6907 initial checkin
fm
parents:
diff changeset
   755
    "Created: / 27-07-2006 / 18:18:52 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   756
    "Modified: / 10-10-2006 / 18:19:05 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   757
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   758
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   759
startPrintJob:aString 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   760
    "Start a print job, using aString as the job title; everything
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   761
     drawn between startPrintJob and endPrintJob will become
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   762
     one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   763
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   764
    ^ self startPrintJob:aString fileName:nil
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   765
8f5996be6907 initial checkin
fm
parents:
diff changeset
   766
    "Created: / 27-07-2006 / 18:19:09 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   767
    "Modified: / 10-10-2006 / 18:19:12 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   768
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
   769
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   770
startPrintJob:aString fileName:aFileName 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   771
    "Start a print job, using aString as the job title; everything
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   772
     drawn between startPrintJob and endPrintJob will become
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   773
     one entry in the print queue."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   774
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   775
    |docInfoStruct nameAddress title fileNameAddress|
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   776
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   777
    gcId isNil ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   778
        self buildPrinter
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   779
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   780
    abort := false.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   781
    title := aString ? 'Smalltalk/X'.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   782
    nameAddress := title asExternalBytes unprotectFromGC.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   783
    aFileName isNil ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   784
        fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   785
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   786
    docInfoStruct := Win32OperatingSystem::DocInfoStructure new.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   787
    docInfoStruct
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   788
        cbSize:docInfoStruct sizeInBytes;
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   789
        lpszDocName:nameAddress address.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   790
    fileNameAddress isNil ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   791
        docInfoStruct lpszOutput:fileNameAddress address
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   792
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   793
    jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   794
    jobid > 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   795
        jobid = -1 ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   796
            abort := true.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   797
            ^ nil
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   798
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   799
        ^ self error
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   800
    ].
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
   801
    self startPage
8f5996be6907 initial checkin
fm
parents:
diff changeset
   802
8f5996be6907 initial checkin
fm
parents:
diff changeset
   803
    "Created: / 27-07-2006 / 18:19:31 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
   804
    "Modified: / 03-08-2006 / 15:11:19 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   805
    "Modified: / 10-10-2006 / 18:20:01 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   806
! !
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   807
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   808
!PrinterContext methodsFor:'queries'!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   809
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   810
supportsColor
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   811
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   812
"/    | retVal info |
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   813
"/
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   814
"/    info := (self class getPrinterInformation: self name) asUppercase.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   815
"/    (info includesSubstring: ',PSCRIPT,')
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   816
"/    ifTrue: [
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   817
"/        retVal := (DAPASX::DapasSystemInfo getYesNoInfoApp: 'Printer' profile: 'PostScriptBlackWhite') not.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   818
"/    ]
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   819
"/    ifFalse: [
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   820
"/        retVal := (info includesSubstring: 'PDF')
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   821
"/            ifTrue: [true]
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   822
"/            ifFalse: [self numberOfColorBitsPerPixel > 1].
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   823
"/    ].
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   824
"/
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   825
"/    ^retVal
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   826
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   827
    ^ false.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   828
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   829
    "Created: / 03-08-2006 / 09:55:26 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   830
    "Modified: / 04-08-2006 / 13:20:40 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   831
    "Modified: / 10-10-2006 / 18:21:07 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   832
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   833
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   834
supportsGraphics
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   835
    ^(OperatingSystem getDeviceCaps: gcId asParameter index: 2 "Technology") ~= 4
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   836
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   837
    "Created: / 03-08-2006 / 10:07:43 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   838
    "Modified: / 10-10-2006 / 18:21:14 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   839
! !
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   840
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   841
!PrinterContext methodsFor:'text printing'!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   842
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   843
asArrayOfStringLines:aString in:aRectangle wordWrap:wordWrapBoolean 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   844
    "Private - convert aString into an array of lines; if wordWrapBoolean
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   845
     is true, also perform word wrapping on the lines, within aRectangle."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   846
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   847
    |line lines stream x0 x1 partialLine leftMargin rightMargin partialLineWidth index|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   848
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   849
    stream := ReadStream on:aString.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   850
    lines := OrderedCollection new.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   851
    wordWrapBoolean ifTrue:[
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   852
        leftMargin := aRectangle left.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   853
        rightMargin := aRectangle right
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   854
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   855
    [ stream atEnd ] whileFalse:[
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   856
        line := stream nextLine.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   857
        wordWrapBoolean ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   858
            lines add:line
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   859
        ] ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   860
            x0 := x1 := 1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   861
            1 to:line size do:[:i | 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   862
                ((line at:i) = Character space "32" 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   863
                    and:[ (partialLine := line copyFrom:x0 to:i) trimBlanks notEmpty ]) 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   864
                        ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   865
                            partialLineWidth := self stringWidthOf:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   866
                            (leftMargin + partialLineWidth) > rightMargin ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   867
                                partialLine := line copyFrom:x0 to:x1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   868
                                lines add:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   869
                                x0 := x1 + 1
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   870
                            ] ifFalse:[ x1 := i ]
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   871
                        ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   872
                index := i
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   873
            ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   874
            line isEmpty ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   875
                lines add:line
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   876
            ] ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   877
                partialLine := line copyFrom:x0 to:index.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   878
                partialLineWidth := self stringWidthOf:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   879
                (leftMargin + partialLineWidth) > rightMargin ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   880
                    partialLine := line copyFrom:x0 to:x1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   881
                    lines add:partialLine.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   882
                    partialLine := line copyFrom:x1 + 1 to:index
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   883
                ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   884
                lines add:partialLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   885
            ]
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   886
        ]
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   887
    ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   888
    ^ lines asArray
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   889
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   890
    "Created: / 02-08-2006 / 17:56:51 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   891
    "Modified: / 04-08-2006 / 13:39:50 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   892
    "Modified: / 10-10-2006 / 18:14:00 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   893
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   894
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   895
displayStringLines:anIndexedCollection from:startIndex to:endIndex in:aRectangle 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   896
    "Private - display Strings in anIndexedCollection starting at startIndex and
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   897
     ending at endIndex, clipped within the bounds of aRectangle."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   898
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   899
    |charHeight ta region ascent|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   900
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   901
    charHeight := self getCharHeight.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   902
    ascent := self font ascentOn:self device.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   903
    startIndex to:endIndex do:[:i | 
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   904
        |lineToPrint|
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   905
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   906
        lineToPrint := (anIndexedCollection at:i).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   907
        self device 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   908
            displayString:lineToPrint
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   909
            from:1
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   910
            to:lineToPrint size
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   911
            x:aRectangle left
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   912
            y:(aRectangle top + ((i - startIndex) * charHeight))
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   913
            in:nil
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   914
            with:gcId
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   915
            opaque:false
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   916
            fontAscent:ascent.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   917
    ].
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   918
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   919
    "/    region := self setClipRect: aRectangle.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   920
    "/    ta := self getTextAlign.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   921
    "/    self setTextAlign: TaTop.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   922
    "/    startIndex to: endIndex do: [ :i |
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   923
    "/        self
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   924
    "/            displayText: ( anIndexedCollection at: i )
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   925
    "/            at: aRectangle left @ ( aRectangle top + ( i - startIndex * charHeight ) ) ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   926
    "/    self setTextAlign: ta.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   927
    "/    self destroyRegion: region
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   928
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   929
    "Created: / 03-08-2006 / 11:37:52 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   930
    "Modified: / 03-08-2006 / 12:38:43 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   931
    "Modified: / 10-10-2006 / 18:14:36 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   932
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   933
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   934
displayStringLines:anIndexedCollection in:aRectangle 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   935
    "Private - display anIndexedCollection of Strings clipped within
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   936
     the bounds of aRectangle."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   937
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   938
    self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   939
        displayStringLines:anIndexedCollection
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   940
        from:1
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   941
        to:anIndexedCollection size
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   942
        in:aRectangle
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   943
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   944
    "Created: / 03-08-2006 / 16:03:07 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   945
    "Modified: / 10-10-2006 / 18:14:40 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   946
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   947
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   948
marginsRectangleFor:aRectangle 
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   949
    "Private - Answer a Rectangle defining margins based on aRectangle.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   950
     Units for aRectangle are in inches, returned margins rectangle is
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   951
     in device units (pixels)."
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   952
    
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   953
    |left top right bottom pixelsPerInchX pixelsPerInchY horzRes vertRes inset rectangle|
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   954
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   955
    pixelsPerInchX := self pixelsPerInchOfScreenWidth.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   956
    pixelsPerInchY := self pixelsPerInchOfScreenHeight.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   957
    aRectangle isNil ifTrue:[
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   958
        horzRes := self printerWidthArea.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   959
        vertRes := self printerHeightArea.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   960
        inset := self class defaultMargins.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   961
        left := (inset x * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   962
        top := (inset y * pixelsPerInchY) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   963
        right := horzRes - (inset x * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   964
        bottom := vertRes - (inset y * pixelsPerInchY) asInteger
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   965
    ] ifFalse:[
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   966
        left := (aRectangle left * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   967
        top := (aRectangle top * pixelsPerInchY) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   968
        right := (aRectangle right * pixelsPerInchX) asInteger.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   969
        bottom := (aRectangle bottom * pixelsPerInchY) asInteger
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   970
    ].
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   971
    rectangle := left @ top extent:right @ bottom.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   972
    ^ rectangle
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   973
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   974
    "Created: / 27-07-2006 / 18:22:57 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   975
    "Modified: / 04-08-2006 / 13:39:45 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   976
    "Modified: / 10-10-2006 / 18:15:26 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   977
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   978
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   979
printPage:pageIndex in:aRectangle lines:lines headerLines:headerLines linesPerPage:linesPerPage 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   980
    "Private - print page # pageIndex from lines, assuming
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   981
     the given number of linesPerPage."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   982
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   983
    |firstLine lastLine l indexString p cHeight rect hLines|
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   984
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   985
    firstLine := (pageIndex - 1) * linesPerPage + 1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   986
    lastLine := (firstLine + linesPerPage - 1) min:lines size.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   987
    rect := aRectangle deepCopy.
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
   988
    hLines := headerLines deepCopy.
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   989
    headerLines size > 0 ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   990
        l := hLines first.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   991
        (p := l indexOfString:'#P') = 0 ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   992
            indexString := pageIndex printString , ' '.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   993
            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
   994
            hLines at:1 put:l.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   995
        ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   996
        cHeight := self getCharHeight.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   997
        rect top:rect top + (hLines size * cHeight).
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   998
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
   999
    self displayStringLines:hLines in:aRectangle.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1000
    self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1001
        displayStringLines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1002
        from:firstLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1003
        to:lastLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1004
        in:rect.
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1005
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1006
    "Created: / 27-07-2006 / 18:28:00 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1007
    "Modified: / 03-08-2006 / 16:03:15 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1008
    "Modified: / 10-10-2006 / 18:18:15 / cg"
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1009
!
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1010
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1011
printPage:pageIndex in:aRectangle lines:lines linesPerPage:linesPerPage 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1012
    "Private - print page # pageIndex from lines, assuming
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1013
     the given number of linesPerPage."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1014
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1015
    |firstLine lastLine|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1016
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1017
    firstLine := (pageIndex - 1) * linesPerPage + 1.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1018
    lastLine := (firstLine + linesPerPage - 1) min:lines size.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1019
    self 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1020
        displayStringLines:lines
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1021
        from:firstLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1022
        to:lastLine
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1023
        in:aRectangle
2147
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1024
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1025
    "Created: / 27-07-2006 / 18:24:59 / fm"
10c893aa772a *** empty log message ***
fm
parents: 2146
diff changeset
  1026
    "Modified: / 03-08-2006 / 12:47:24 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1027
    "Modified: / 10-10-2006 / 18:18:22 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1028
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1029
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1030
stringWidthOf:aString 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1031
    "Return the width of aString
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1032
     when written using the current font."
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1033
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1034
    ^ self stringWidthOf:aString at:aString size.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1035
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1036
    "Modified: / 03-08-2006 / 10:18:23 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1037
    "Modified: / 10-10-2006 / 18:20:08 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1038
!
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1039
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1040
stringWidthOf:aString at:index 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1041
    "Return the width of aString up to index
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1042
     when written using the current font; expand tabs out
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1043
     to 4 spaces for calculations"
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1044
    
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1045
    |answer str size spaceWidth|
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1046
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1047
    index <= 0 ifTrue:[ ^ 0 ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1048
    str := index >= aString size ifTrue:[ aString ] ifFalse:[ aString copyFrom:1 to:index ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1049
    true "self font isNil" ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1050
        "if font not set yet, calculate based on default font"
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1051
        "/            extString := str asExternalString.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1052
        size := Win32OperatingSystem::WinPointStructure new.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1053
        (OperatingSystem 
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1054
            getTextExtentPoint:gcId
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1055
            string:str
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1056
            size:size) ifFalse:[ ^ self error ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1057
        answer := size x.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1058
        #TODO.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1059
    ] ifFalse:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1060
        answer := self font widthOf:str on:self device
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1061
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1062
    index > aString size ifTrue:[
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1063
        spaceWidth := self font widthOf:Character space on:self device.
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1064
        answer := answer + ((index - aString size) * spaceWidth)
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1065
    ].
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1066
    ^ answer.
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1067
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1068
    "Created: / 03-08-2006 / 10:27:20 / fm"
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1069
    "Modified: / 04-08-2006 / 12:27:26 / fm"
2236
76291d984db9 pretty printing
Claus Gittinger <cg@exept.de>
parents: 2235
diff changeset
  1070
    "Modified: / 10-10-2006 / 18:20:43 / cg"
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1071
! !
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1072
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1073
!PrinterContext class methodsFor:'documentation'!
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1074
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1075
version
2237
950fb103a14e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2236
diff changeset
  1076
    ^ '$Header: /cvs/stx/stx/libview2/PrinterContext.st,v 1.7 2006-10-10 18:25:51 cg Exp $'
2143
8f5996be6907 initial checkin
fm
parents:
diff changeset
  1077
! !