]>
Commit | Line | Data |
---|---|---|
ed880dd4 | 1 | ///////////////////////////////////////////////////////////////////////////// |
bf38cbff JS |
2 | // Name: dcpsg.cpp |
3 | // Purpose: Generic wxPostScriptDC implementation | |
ed880dd4 RR |
4 | // Author: Julian Smart, Robert Roebling, Markus Holzhem |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9a6be59a | 9 | // Licence: wxWindows licence |
ed880dd4 RR |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
ed880dd4 RR |
13 | #pragma implementation |
14 | #pragma interface | |
15 | #endif | |
16 | ||
9a6be59a VZ |
17 | #include "wx/wxprec.h" |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/setup.h" | |
25 | #include "wx/defs.h" | |
26 | #endif // WX_PRECOMP | |
06cfab17 | 27 | |
ce4169a4 RR |
28 | #if wxUSE_PRINTING_ARCHITECTURE |
29 | ||
06cfab17 RR |
30 | #if wxUSE_POSTSCRIPT |
31 | ||
f04371f0 | 32 | #include "wx/dcmemory.h" |
ed880dd4 | 33 | #include "wx/utils.h" |
f04371f0 | 34 | #include "wx/intl.h" |
ed880dd4 | 35 | #include "wx/filedlg.h" |
ed880dd4 | 36 | #include "wx/app.h" |
f04371f0 | 37 | #include "wx/msgdlg.h" |
ef539066 | 38 | #include "wx/image.h" |
3069ac4e | 39 | #include "wx/log.h" |
bf38cbff JS |
40 | #include "wx/generic/dcpsg.h" |
41 | #include "wx/generic/prntdlgg.h" | |
42 | #include "wx/button.h" | |
43 | #include "wx/stattext.h" | |
44 | #include "wx/radiobox.h" | |
45 | #include "wx/textctrl.h" | |
9a05fd8d | 46 | #include "wx/prntbase.h" |
7bcb11d3 | 47 | #include "wx/paper.h" |
ed880dd4 | 48 | |
57c208c5 JS |
49 | #include <math.h> |
50 | ||
bf38cbff JS |
51 | #ifdef __WXMSW__ |
52 | ||
53 | #ifdef DrawText | |
54 | #undef DrawText | |
55 | #endif | |
56 | ||
57 | #ifdef StartDoc | |
58 | #undef StartDoc | |
59 | #endif | |
60 | ||
61 | #ifdef GetCharWidth | |
62 | #undef GetCharWidth | |
63 | #endif | |
64 | ||
65 | #ifdef FindWindow | |
66 | #undef FindWindow | |
67 | #endif | |
68 | ||
69 | #endif | |
70 | ||
ed880dd4 RR |
71 | //----------------------------------------------------------------------------- |
72 | // start and end of document/page | |
73 | //----------------------------------------------------------------------------- | |
74 | ||
75 | static const char *wxPostScriptHeaderEllipse = "\ | |
76 | /ellipsedict 8 dict def\n\ | |
77 | ellipsedict /mtrx matrix put\n\ | |
78 | /ellipse {\n\ | |
9a6be59a VZ |
79 | ellipsedict begin\n\ |
80 | /endangle exch def\n\ | |
81 | /startangle exch def\n\ | |
82 | /yrad exch def\n\ | |
83 | /xrad exch def\n\ | |
84 | /y exch def\n\ | |
85 | /x exch def\n\ | |
86 | /savematrix mtrx currentmatrix def\n\ | |
87 | x y translate\n\ | |
88 | xrad yrad scale\n\ | |
89 | 0 0 1 startangle endangle arc\n\ | |
90 | savematrix setmatrix\n\ | |
91 | end\n\ | |
92 | } def\n\ | |
ed880dd4 RR |
93 | "; |
94 | ||
95 | static const char *wxPostScriptHeaderEllipticArc= "\ | |
96 | /ellipticarcdict 8 dict def\n\ | |
97 | ellipticarcdict /mtrx matrix put\n\ | |
98 | /ellipticarc\n\ | |
99 | { ellipticarcdict begin\n\ | |
100 | /do_fill exch def\n\ | |
101 | /endangle exch def\n\ | |
102 | /startangle exch def\n\ | |
103 | /yrad exch def\n\ | |
104 | /xrad exch def \n\ | |
105 | /y exch def\n\ | |
106 | /x exch def\n\ | |
107 | /savematrix mtrx currentmatrix def\n\ | |
108 | x y translate\n\ | |
109 | xrad yrad scale\n\ | |
110 | do_fill { 0 0 moveto } if\n\ | |
111 | 0 0 1 startangle endangle arc\n\ | |
112 | savematrix setmatrix\n\ | |
113 | do_fill { fill }{ stroke } ifelse\n\ | |
114 | end\n\ | |
115 | } def\n"; | |
116 | ||
117 | static const char *wxPostScriptHeaderSpline = "\ | |
118 | /DrawSplineSection {\n\ | |
9a6be59a VZ |
119 | /y3 exch def\n\ |
120 | /x3 exch def\n\ | |
121 | /y2 exch def\n\ | |
122 | /x2 exch def\n\ | |
123 | /y1 exch def\n\ | |
124 | /x1 exch def\n\ | |
125 | /xa x1 x2 x1 sub 0.666667 mul add def\n\ | |
126 | /ya y1 y2 y1 sub 0.666667 mul add def\n\ | |
127 | /xb x3 x2 x3 sub 0.666667 mul add def\n\ | |
128 | /yb y3 y2 y3 sub 0.666667 mul add def\n\ | |
129 | x1 y1 lineto\n\ | |
130 | xa ya xb yb x3 y3 curveto\n\ | |
131 | } def\n\ | |
ed880dd4 RR |
132 | "; |
133 | ||
134 | static const char *wxPostScriptHeaderColourImage = "\ | |
135 | % define 'colorimage' if it isn't defined\n\ | |
136 | % ('colortogray' and 'mergeprocs' come from xwd2ps\n\ | |
137 | % via xgrab)\n\ | |
138 | /colorimage where % do we know about 'colorimage'?\n\ | |
139 | { pop } % yes: pop off the 'dict' returned\n\ | |
140 | { % no: define one\n\ | |
141 | /colortogray { % define an RGB->I function\n\ | |
142 | /rgbdata exch store % call input 'rgbdata'\n\ | |
143 | rgbdata length 3 idiv\n\ | |
144 | /npixls exch store\n\ | |
145 | /rgbindx 0 store\n\ | |
146 | 0 1 npixls 1 sub {\n\ | |
147 | grays exch\n\ | |
148 | rgbdata rgbindx get 20 mul % Red\n\ | |
149 | rgbdata rgbindx 1 add get 32 mul % Green\n\ | |
150 | rgbdata rgbindx 2 add get 12 mul % Blue\n\ | |
151 | add add 64 idiv % I = .5G + .31R + .18B\n\ | |
152 | put\n\ | |
153 | /rgbindx rgbindx 3 add store\n\ | |
154 | } for\n\ | |
155 | grays 0 npixls getinterval\n\ | |
156 | } bind def\n\ | |
157 | \n\ | |
158 | % Utility procedure for colorimage operator.\n\ | |
159 | % This procedure takes two procedures off the\n\ | |
160 | % stack and merges them into a single procedure.\n\ | |
161 | \n\ | |
162 | /mergeprocs { % def\n\ | |
163 | dup length\n\ | |
164 | 3 -1 roll\n\ | |
165 | dup\n\ | |
166 | length\n\ | |
167 | dup\n\ | |
168 | 5 1 roll\n\ | |
169 | 3 -1 roll\n\ | |
170 | add\n\ | |
171 | array cvx\n\ | |
172 | dup\n\ | |
173 | 3 -1 roll\n\ | |
174 | 0 exch\n\ | |
175 | putinterval\n\ | |
176 | dup\n\ | |
177 | 4 2 roll\n\ | |
178 | putinterval\n\ | |
179 | } bind def\n\ | |
180 | \n\ | |
181 | /colorimage { % def\n\ | |
182 | pop pop % remove 'false 3' operands\n\ | |
183 | {colortogray} mergeprocs\n\ | |
184 | image\n\ | |
185 | } bind def\n\ | |
186 | } ifelse % end of 'false' case\n\ | |
187 | "; | |
188 | ||
189 | static char wxPostScriptHeaderReencodeISO1[] = | |
190 | "\n/reencodeISO {\n" | |
191 | "dup dup findfont dup length dict begin\n" | |
192 | "{ 1 index /FID ne { def }{ pop pop } ifelse } forall\n" | |
193 | "/Encoding ISOLatin1Encoding def\n" | |
194 | "currentdict end definefont\n" | |
195 | "} def\n" | |
196 | "/ISOLatin1Encoding [\n" | |
197 | "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n" | |
198 | "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n" | |
199 | "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n" | |
200 | "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n" | |
201 | "/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n" | |
202 | "/parenleft/parenright/asterisk/plus/comma/minus/period/slash\n" | |
203 | "/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon\n" | |
204 | "/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N\n" | |
205 | "/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright\n" | |
206 | "/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m\n" | |
207 | "/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde\n" | |
208 | "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n" | |
209 | "/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n" | |
210 | "/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve\n" | |
211 | "/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut\n"; | |
212 | ||
213 | static char wxPostScriptHeaderReencodeISO2[] = | |
214 | "/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar\n" | |
215 | "/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot\n" | |
216 | "/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior\n" | |
217 | "/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine\n" | |
218 | "/guillemotright/onequarter/onehalf/threequarters/questiondown\n" | |
219 | "/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla\n" | |
220 | "/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n" | |
221 | "/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n" | |
222 | "/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute\n" | |
223 | "/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis\n" | |
224 | "/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave\n" | |
225 | "/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex\n" | |
226 | "/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis\n" | |
227 | "/yacute/thorn/ydieresis\n" | |
228 | "] def\n\n"; | |
229 | ||
ed880dd4 RR |
230 | //------------------------------------------------------------------------------- |
231 | // wxPostScriptDC | |
232 | //------------------------------------------------------------------------------- | |
233 | ||
234 | wxPostScriptDC::wxPostScriptDC () | |
235 | { | |
236 | m_pstream = (ofstream*) NULL; | |
afce4c03 | 237 | |
ed880dd4 RR |
238 | m_currentRed = 0; |
239 | m_currentGreen = 0; | |
240 | m_currentBlue = 0; | |
afce4c03 | 241 | |
ed880dd4 | 242 | m_pageNumber = 0; |
afce4c03 | 243 | |
ed880dd4 | 244 | m_clipping = FALSE; |
afce4c03 | 245 | |
ed880dd4 RR |
246 | m_underlinePosition = 0.0; |
247 | m_underlineThickness = 0.0; | |
248 | ||
249 | m_signX = 1; // default x-axis left to right | |
250 | m_signY = -1; // default y-axis bottom up -> top down | |
7bcb11d3 JS |
251 | |
252 | // Compatibility only | |
253 | m_printData = * wxThePrintSetupData; | |
ed880dd4 RR |
254 | } |
255 | ||
256 | wxPostScriptDC::wxPostScriptDC (const wxString& file, bool interactive, wxWindow *parent) | |
257 | { | |
258 | m_pstream = (ofstream*) NULL; | |
afce4c03 | 259 | |
ed880dd4 RR |
260 | m_currentRed = 0; |
261 | m_currentGreen = 0; | |
262 | m_currentBlue = 0; | |
afce4c03 | 263 | |
ed880dd4 | 264 | m_pageNumber = 0; |
afce4c03 | 265 | |
ed880dd4 | 266 | m_clipping = FALSE; |
afce4c03 | 267 | |
ed880dd4 RR |
268 | m_underlinePosition = 0.0; |
269 | m_underlineThickness = 0.0; | |
270 | ||
271 | m_signX = 1; // default x-axis left to right | |
272 | m_signY = -1; // default y-axis bottom up -> top down | |
273 | ||
274 | Create(file, interactive, parent); | |
275 | } | |
276 | ||
277 | bool wxPostScriptDC::Create(const wxString& file, bool interactive, wxWindow *parent) | |
278 | { | |
279 | m_isInteractive = interactive; | |
280 | ||
281 | m_title = ""; | |
7bcb11d3 | 282 | m_printData.SetFilename(file); |
ed880dd4 RR |
283 | |
284 | #ifdef __WXMSW__ | |
285 | // Can only send to file in Windows | |
7bcb11d3 | 286 | m_printData.SetPrintMode(wxPRINT_MODE_FILE); |
ed880dd4 RR |
287 | #endif |
288 | ||
289 | if (m_isInteractive) | |
290 | { | |
291 | if ((m_ok = PrinterDialog (parent) ) == FALSE) return FALSE; | |
292 | } | |
293 | else | |
294 | { | |
295 | m_ok = TRUE; | |
296 | } | |
afce4c03 | 297 | |
ed880dd4 RR |
298 | return m_ok; |
299 | } | |
300 | ||
7bcb11d3 JS |
301 | wxPostScriptDC::wxPostScriptDC (const wxPrintData& printData) |
302 | { | |
303 | m_pstream = (ofstream*) NULL; | |
304 | ||
305 | m_currentRed = 0; | |
306 | m_currentGreen = 0; | |
307 | m_currentBlue = 0; | |
308 | ||
309 | m_pageNumber = 0; | |
310 | ||
311 | m_clipping = FALSE; | |
312 | ||
313 | m_underlinePosition = 0.0; | |
314 | m_underlineThickness = 0.0; | |
315 | ||
316 | m_signX = 1; // default x-axis left to right | |
317 | m_signY = -1; // default y-axis bottom up -> top down | |
318 | ||
319 | m_printData = printData; | |
75737d05 JS |
320 | |
321 | m_ok = TRUE; | |
7bcb11d3 JS |
322 | } |
323 | ||
ed880dd4 RR |
324 | wxPostScriptDC::~wxPostScriptDC () |
325 | { | |
326 | if (m_pstream) delete m_pstream; | |
327 | } | |
328 | ||
4bc67cc5 RR |
329 | bool wxPostScriptDC::Ok() const |
330 | { | |
ef539066 | 331 | return m_ok; |
4bc67cc5 | 332 | } |
afce4c03 | 333 | |
7bcb11d3 | 334 | // This dialog is deprecated now: use wxGenericPrintDialog or the printing framework |
ed880dd4 RR |
335 | bool wxPostScriptDC::PrinterDialog(wxWindow *parent) |
336 | { | |
afce4c03 | 337 | wxPostScriptPrintDialog dialog( parent, _("Printer Settings"), wxPoint(150, 150), wxSize(400, 400), |
ed880dd4 RR |
338 | wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL ); |
339 | m_ok = (dialog.ShowModal () == wxID_OK); | |
340 | ||
341 | if (!m_ok) return FALSE; | |
342 | ||
7bcb11d3 JS |
343 | if ((m_printData.GetFilename() == "") && |
344 | (m_printData.GetPrintMode() == wxPRINT_MODE_PREVIEW || | |
345 | m_printData.GetPrintMode() == wxPRINT_MODE_PRINTER)) | |
ed880dd4 RR |
346 | { |
347 | // steve, 05.09.94 | |
348 | #ifdef __VMS__ | |
7bcb11d3 | 349 | m_printData.SetFilename("preview"); |
ed880dd4 RR |
350 | #else |
351 | // For PS_PRINTER action this depends on a Unix-style print spooler | |
352 | // since the wx_printer_file can be destroyed during a session | |
353 | // @@@ TODO: a Windows-style answer for non-Unix | |
87138c52 | 354 | wxChar userId[256]; |
ed880dd4 | 355 | wxGetUserId (userId, sizeof (userId) / sizeof (char)); |
87138c52 OK |
356 | wxChar tmp[256]; |
357 | wxStrcpy (tmp, _T("/tmp/preview_")); | |
358 | wxStrcat (tmp, userId); | |
7bcb11d3 | 359 | m_printData.SetFilename(tmp); |
ed880dd4 | 360 | #endif |
87138c52 OK |
361 | wxChar tmp2[256]; |
362 | wxStrcpy(tmp2, m_printData.GetFilename()); | |
363 | wxStrcat (tmp2, _T(".ps")); | |
7bcb11d3 | 364 | m_printData.SetFilename(tmp2); |
ed880dd4 | 365 | } |
87138c52 | 366 | else if ((m_printData.GetFilename() == _T("")) && (m_printData.GetPrintMode() == wxPRINT_MODE_FILE)) |
ed880dd4 | 367 | { |
87138c52 | 368 | wxString file = wxSaveFileSelector (_("PostScript"), _T("ps")); |
ba681060 | 369 | if ( file.IsEmpty() ) |
ed880dd4 RR |
370 | { |
371 | m_ok = FALSE; | |
372 | return FALSE; | |
373 | } | |
ba681060 | 374 | |
7bcb11d3 | 375 | m_printData.SetFilename(file); |
ed880dd4 RR |
376 | m_ok = TRUE; |
377 | } | |
378 | ||
4bc67cc5 | 379 | return m_ok; |
ed880dd4 RR |
380 | } |
381 | ||
382 | void wxPostScriptDC::SetClippingRegion (long x, long y, long w, long h) | |
383 | { | |
87138c52 | 384 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 385 | |
4bc67cc5 | 386 | if (m_clipping) return; |
ed880dd4 RR |
387 | |
388 | wxDC::SetClippingRegion( x, y, w, h ); | |
afce4c03 | 389 | |
ed880dd4 | 390 | m_clipping = TRUE; |
afce4c03 VZ |
391 | *m_pstream << "gsave\n" |
392 | << "newpath\n" | |
9a6be59a VZ |
393 | << XLOG2DEV(x) << " " << YLOG2DEV(y) << " moveto\n" |
394 | << XLOG2DEV(x+w) << " " << YLOG2DEV(y) << " lineto\n" | |
395 | << XLOG2DEV(x+w) << " " << YLOG2DEV(y+h) << " lineto\n" | |
396 | << XLOG2DEV(x) << " " << YLOG2DEV(y+h) << " lineto\n" | |
ed880dd4 RR |
397 | << "closepath clip newpath\n"; |
398 | } | |
399 | ||
400 | void wxPostScriptDC::SetClippingRegion( const wxRegion &WXUNUSED(region) ) | |
401 | { | |
402 | } | |
403 | ||
404 | void wxPostScriptDC::DestroyClippingRegion() | |
405 | { | |
87138c52 | 406 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 407 | |
ed880dd4 | 408 | wxDC::DestroyClippingRegion(); |
afce4c03 | 409 | |
ed880dd4 RR |
410 | if (m_clipping) |
411 | { | |
412 | m_clipping = FALSE; | |
413 | *m_pstream << "grestore\n"; | |
414 | } | |
415 | } | |
416 | ||
417 | void wxPostScriptDC::Clear() | |
418 | { | |
87138c52 | 419 | wxFAIL_MSG( _T("wxPostScriptDC::Clear not implemented.") ); |
ed880dd4 RR |
420 | } |
421 | ||
64698f9a | 422 | void wxPostScriptDC::DoFloodFill (long WXUNUSED(x), long WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style)) |
ed880dd4 | 423 | { |
87138c52 | 424 | wxFAIL_MSG( _T("wxPostScriptDC::FloodFill not implemented.") ); |
ed880dd4 RR |
425 | } |
426 | ||
64698f9a | 427 | bool wxPostScriptDC::DoGetPixel (long WXUNUSED(x), long WXUNUSED(y), wxColour * WXUNUSED(col)) const |
ed880dd4 | 428 | { |
87138c52 | 429 | wxFAIL_MSG( _T("wxPostScriptDC::GetPixel not implemented.") ); |
ed880dd4 RR |
430 | return FALSE; |
431 | } | |
432 | ||
64698f9a | 433 | void wxPostScriptDC::DoCrossHair (long WXUNUSED(x), long WXUNUSED(y)) |
ed880dd4 | 434 | { |
87138c52 | 435 | wxFAIL_MSG( _T("wxPostScriptDC::CrossHair not implemented.") ); |
ed880dd4 RR |
436 | } |
437 | ||
64698f9a | 438 | void wxPostScriptDC::DoDrawLine (long x1, long y1, long x2, long y2) |
ed880dd4 | 439 | { |
87138c52 | 440 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 441 | |
ed880dd4 | 442 | if (m_pen.GetStyle() == wxTRANSPARENT) return; |
afce4c03 | 443 | |
ed880dd4 | 444 | SetPen( m_pen ); |
afce4c03 | 445 | |
ed880dd4 | 446 | *m_pstream << "newpath\n" |
9a6be59a VZ |
447 | << XLOG2DEV(x1) << " " << YLOG2DEV (y1) << " moveto\n" |
448 | << XLOG2DEV(x2) << " " << YLOG2DEV (y2) << " lineto\n" | |
449 | << "stroke\n"; | |
afce4c03 | 450 | |
ed880dd4 RR |
451 | CalcBoundingBox( x1, y1 ); |
452 | CalcBoundingBox( x2, y2 ); | |
453 | } | |
454 | ||
455 | #define RAD2DEG 57.29577951308 | |
456 | ||
64698f9a | 457 | void wxPostScriptDC::DoDrawArc (long x1, long y1, long x2, long y2, long xc, long yc) |
ed880dd4 | 458 | { |
87138c52 | 459 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 460 | |
ed880dd4 RR |
461 | long dx = x1 - xc; |
462 | long dy = y1 - yc; | |
463 | long radius = (long) sqrt(dx*dx+dy*dy); | |
464 | double alpha1, alpha2; | |
465 | ||
afce4c03 | 466 | if (x1 == x2 && y1 == y2) |
ed880dd4 | 467 | { |
9a6be59a VZ |
468 | alpha1 = 0.0; |
469 | alpha2 = 360.0; | |
afce4c03 | 470 | } else if (radius == 0.0) |
ed880dd4 | 471 | { |
9a6be59a | 472 | alpha1 = alpha2 = 0.0; |
afce4c03 | 473 | } else |
ed880dd4 | 474 | { |
9a6be59a VZ |
475 | alpha1 = (x1 - xc == 0) ? |
476 | (y1 - yc < 0) ? 90.0 : -90.0 : | |
477 | -atan2(double(y1-yc), double(x1-xc)) * RAD2DEG; | |
478 | alpha2 = (x2 - xc == 0) ? | |
479 | (y2 - yc < 0) ? 90.0 : -90.0 : | |
480 | -atan2(double(y2-yc), double(x2-xc)) * RAD2DEG; | |
ed880dd4 RR |
481 | } |
482 | while (alpha1 <= 0) alpha1 += 360; | |
483 | while (alpha2 <= 0) alpha2 += 360; // adjust angles to be between | |
484 | while (alpha1 > 360) alpha1 -= 360; // 0 and 360 degree | |
485 | while (alpha2 > 360) alpha2 -= 360; | |
486 | ||
afce4c03 | 487 | if (m_brush.GetStyle() != wxTRANSPARENT) |
ed880dd4 | 488 | { |
9a6be59a VZ |
489 | SetBrush( m_brush ); |
490 | *m_pstream << "newpath\n" | |
491 | << XLOG2DEV(xc) << " " | |
492 | << YLOG2DEV(yc) << " " | |
493 | << XLOG2DEVREL(radius) << " " | |
494 | << YLOG2DEVREL(radius) << " " | |
495 | << alpha1 << " " | |
496 | << alpha2 << " ellipse\n" | |
497 | << XLOG2DEV(xc) << " " | |
498 | << YLOG2DEV(yc) << " lineto\n" | |
499 | << "closepath\n" | |
500 | << "fill\n"; | |
ed880dd4 | 501 | } |
afce4c03 VZ |
502 | |
503 | if (m_pen.GetStyle() != wxTRANSPARENT) | |
ed880dd4 | 504 | { |
9a6be59a VZ |
505 | SetPen( m_pen ); |
506 | *m_pstream << "newpath\n" | |
507 | << XLOG2DEV(xc) << " " | |
508 | << YLOG2DEV(yc) << " " | |
509 | << XLOG2DEVREL(radius) << " " | |
510 | << YLOG2DEVREL(radius) << " " | |
511 | << alpha1 << " " | |
512 | << alpha2 << " ellipse\n" | |
513 | << "stroke\n"; | |
ed880dd4 | 514 | } |
afce4c03 | 515 | |
ed880dd4 RR |
516 | CalcBoundingBox( xc-radius, yc-radius ); |
517 | CalcBoundingBox( xc+radius, yc+radius ); | |
518 | } | |
519 | ||
64698f9a | 520 | void wxPostScriptDC::DoDrawEllipticArc(long x,long y,long w,long h,double sa,double ea) |
ed880dd4 | 521 | { |
87138c52 | 522 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 523 | |
ed880dd4 RR |
524 | if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360; |
525 | if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360; | |
526 | if (sa<0) sa+=360; | |
527 | if (ea<0) ea+=360; | |
afce4c03 | 528 | |
ed880dd4 RR |
529 | if (sa==ea) |
530 | { | |
531 | DrawEllipse(x,y,w,h); | |
532 | return; | |
533 | } | |
534 | ||
535 | if (m_brush.GetStyle () != wxTRANSPARENT) | |
536 | { | |
537 | SetBrush( m_brush ); | |
538 | ||
afce4c03 VZ |
539 | *m_pstream << "newpath\n" |
540 | << XLOG2DEV(x+w/2) << " " << YLOG2DEV(y+h/2) << " " | |
541 | << XLOG2DEVREL(w/2) << " " << YLOG2DEVREL(h/2) << " " | |
9a6be59a | 542 | << int(sa) <<" "<< int(ea) << " true ellipticarc\n"; |
ed880dd4 RR |
543 | |
544 | CalcBoundingBox( x ,y ); | |
545 | CalcBoundingBox( x+w, y+h ); | |
546 | } | |
afce4c03 | 547 | |
ed880dd4 RR |
548 | if (m_pen.GetStyle () != wxTRANSPARENT) |
549 | { | |
550 | SetPen( m_pen ); | |
551 | ||
afce4c03 VZ |
552 | *m_pstream << "newpath\n" |
553 | << XLOG2DEV(x+w/2) << " " << YLOG2DEV(y+h/2) << " " | |
554 | << XLOG2DEVREL(w/2) << " " << XLOG2DEVREL(h/2) << " " | |
9a6be59a | 555 | << int(sa) <<" "<< int(ea) << " false ellipticarc\n"; |
ed880dd4 RR |
556 | |
557 | CalcBoundingBox( x, y ); | |
558 | CalcBoundingBox( x+w, y+h ); | |
559 | } | |
560 | } | |
561 | ||
64698f9a | 562 | void wxPostScriptDC::DoDrawPoint (long x, long y) |
ed880dd4 | 563 | { |
87138c52 | 564 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 565 | |
ed880dd4 | 566 | if (m_pen.GetStyle() == wxTRANSPARENT) return; |
afce4c03 | 567 | |
ed880dd4 | 568 | SetPen (m_pen); |
afce4c03 | 569 | |
ed880dd4 | 570 | *m_pstream << "newpath\n" |
9a6be59a VZ |
571 | << XLOG2DEV(x) << " " << YLOG2DEV (y) << " moveto\n" |
572 | << XLOG2DEV(x+1) << " " << YLOG2DEV (y) << " lineto\n" | |
573 | << "stroke\n"; | |
afce4c03 | 574 | |
ed880dd4 RR |
575 | CalcBoundingBox( x, y ); |
576 | } | |
577 | ||
64698f9a | 578 | void wxPostScriptDC::DoDrawPolygon (int n, wxPoint points[], long xoffset, long yoffset, int WXUNUSED(fillStyle)) |
ed880dd4 | 579 | { |
87138c52 | 580 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 581 | |
ed880dd4 | 582 | if (n <= 0) return; |
afce4c03 | 583 | |
ed880dd4 RR |
584 | if (m_brush.GetStyle () != wxTRANSPARENT) |
585 | { | |
9a6be59a | 586 | SetBrush( m_brush ); |
afce4c03 | 587 | |
9a6be59a | 588 | *m_pstream << "newpath\n"; |
ed880dd4 | 589 | |
9a6be59a VZ |
590 | long xx = XLOG2DEV(points[0].x + xoffset); |
591 | long yy = YLOG2DEV(points[0].y + yoffset); | |
592 | *m_pstream << xx << " " << yy << " moveto\n"; | |
593 | CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset ); | |
ed880dd4 | 594 | |
9a6be59a VZ |
595 | for (int i = 1; i < n; i++) |
596 | { | |
597 | xx = XLOG2DEV(points[i].x + xoffset); | |
598 | yy = YLOG2DEV(points[i].y + yoffset); | |
599 | *m_pstream << xx << " " << yy << " lineto\n"; | |
600 | CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset); | |
601 | } | |
602 | *m_pstream << "fill\n"; | |
ed880dd4 RR |
603 | } |
604 | ||
605 | if (m_pen.GetStyle () != wxTRANSPARENT) | |
606 | { | |
9a6be59a | 607 | SetPen( m_pen ); |
afce4c03 | 608 | |
9a6be59a | 609 | *m_pstream << "newpath\n"; |
ed880dd4 | 610 | |
9a6be59a VZ |
611 | long xx = XLOG2DEV(points[0].x + xoffset); |
612 | long yy = YLOG2DEV(points[0].y + yoffset); | |
613 | *m_pstream << xx << " " << yy << " moveto\n"; | |
614 | CalcBoundingBox( points[0].x + xoffset, points[0].y + yoffset ); | |
ed880dd4 | 615 | |
9a6be59a VZ |
616 | for (int i = 1; i < n; i++) |
617 | { | |
618 | xx = XLOG2DEV(points[i].x + xoffset); | |
619 | yy = YLOG2DEV(points[i].y + yoffset); | |
620 | *m_pstream << xx << " " << yy << " lineto\n"; | |
621 | CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset); | |
622 | } | |
ed880dd4 | 623 | |
9a6be59a | 624 | *m_pstream << "stroke\n"; |
ed880dd4 RR |
625 | } |
626 | } | |
627 | ||
64698f9a | 628 | void wxPostScriptDC::DoDrawLines (int n, wxPoint points[], long xoffset, long yoffset) |
ed880dd4 | 629 | { |
87138c52 | 630 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 631 | |
9a6be59a VZ |
632 | if (m_pen.GetStyle() == wxTRANSPARENT) |
633 | return; | |
634 | if (n <= 0) | |
635 | return; | |
afce4c03 | 636 | |
ed880dd4 | 637 | SetPen (m_pen); |
afce4c03 | 638 | |
9a6be59a VZ |
639 | int i; |
640 | for ( i =0; i<n ; i++ ) | |
ed880dd4 | 641 | { |
9a6be59a | 642 | CalcBoundingBox( XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset)); |
ed880dd4 RR |
643 | } |
644 | ||
645 | *m_pstream << "newpath\n" | |
646 | << XLOG2DEV(points[0].x+xoffset) << " " | |
9a6be59a | 647 | << YLOG2DEV(points[0].y+yoffset) << " moveto\n"; |
afce4c03 VZ |
648 | |
649 | for (i = 1; i < n; i++) | |
ed880dd4 | 650 | { |
9a6be59a VZ |
651 | *m_pstream << XLOG2DEV(points[i].x+xoffset) << " " |
652 | << YLOG2DEV(points[i].y+yoffset) << " lineto\n"; | |
ed880dd4 | 653 | } |
afce4c03 | 654 | |
ed880dd4 RR |
655 | *m_pstream << "stroke\n"; |
656 | } | |
657 | ||
64698f9a | 658 | void wxPostScriptDC::DoDrawRectangle (long x, long y, long width, long height) |
ed880dd4 | 659 | { |
87138c52 | 660 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 661 | |
ed880dd4 RR |
662 | if (m_brush.GetStyle () != wxTRANSPARENT) |
663 | { | |
664 | SetBrush( m_brush ); | |
665 | ||
666 | *m_pstream << "newpath\n" | |
667 | << XLOG2DEV(x) << " " << YLOG2DEV(y) << " moveto\n" | |
668 | << XLOG2DEV(x + width) << " " << YLOG2DEV(y) << " lineto\n" | |
669 | << XLOG2DEV(x + width) << " " << YLOG2DEV(y + height) << " lineto\n" | |
670 | << XLOG2DEV(x) << " " << YLOG2DEV(y + height) << " lineto\n" | |
671 | << "closepath\n" | |
672 | << "fill\n"; | |
673 | ||
674 | CalcBoundingBox( x, y ); | |
675 | CalcBoundingBox( x + width, y + height ); | |
676 | } | |
afce4c03 | 677 | |
ed880dd4 RR |
678 | if (m_pen.GetStyle () != wxTRANSPARENT) |
679 | { | |
680 | SetPen (m_pen); | |
681 | ||
682 | *m_pstream << "newpath\n" | |
683 | << XLOG2DEV(x) << " " << YLOG2DEV(y) << " moveto\n" | |
684 | << XLOG2DEV(x + width) << " " << YLOG2DEV(y) << " lineto\n" | |
685 | << XLOG2DEV(x + width) << " " << YLOG2DEV(y + height) << " lineto\n" | |
686 | << XLOG2DEV(x) << " " << YLOG2DEV(y + height) << " lineto\n" | |
687 | << "closepath\n" | |
688 | << "stroke\n"; | |
689 | ||
690 | CalcBoundingBox( x, y ); | |
691 | CalcBoundingBox( x + width, y + height ); | |
692 | } | |
693 | } | |
694 | ||
64698f9a | 695 | void wxPostScriptDC::DoDrawRoundedRectangle (long x, long y, long width, long height, double radius) |
ed880dd4 | 696 | { |
87138c52 | 697 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 698 | |
ed880dd4 RR |
699 | if (radius < 0.0) |
700 | { | |
701 | // Now, a negative radius is interpreted to mean | |
702 | // 'the proportion of the smallest X or Y dimension' | |
703 | double smallest = 0.0; | |
704 | if (width < height) | |
9a6be59a | 705 | smallest = width; |
ed880dd4 | 706 | else |
9a6be59a | 707 | smallest = height; |
ed880dd4 RR |
708 | radius = (-radius * smallest); |
709 | } | |
afce4c03 | 710 | |
ed880dd4 RR |
711 | long rad = (long) radius; |
712 | ||
713 | if (m_brush.GetStyle () != wxTRANSPARENT) | |
714 | { | |
715 | SetBrush( m_brush ); | |
afce4c03 | 716 | |
ed880dd4 RR |
717 | // Draw rectangle anticlockwise |
718 | *m_pstream << "newpath\n" | |
719 | << XLOG2DEV(x + rad) << " " << YLOG2DEV(y + rad) << " " << XLOG2DEVREL(rad) << " 90 180 arc\n" | |
720 | << XLOG2DEV(x) << " " << YLOG2DEV(y + rad) << " moveto\n" | |
721 | << XLOG2DEV(x + rad) << " " << YLOG2DEV(y + height - rad) << " " << XLOG2DEVREL(rad) << " 180 270 arc\n" | |
722 | << XLOG2DEV(x + width - rad) << " " << YLOG2DEV(y + height) << " lineto\n" | |
723 | << XLOG2DEV(x + width - rad) << " " << YLOG2DEV(y + height - rad) << " " << XLOG2DEVREL(rad) << " 270 0 arc\n" | |
724 | << XLOG2DEV(x + width) << " " << YLOG2DEV(y + rad) << " lineto\n" | |
725 | << XLOG2DEV(x + width - rad) << " " << YLOG2DEV(y + rad) << " " << XLOG2DEVREL(rad) << " 0 90 arc\n" | |
726 | << XLOG2DEV(x + rad) << " " << YLOG2DEV(y) << " lineto\n" | |
727 | << "closepath\n" | |
728 | << "fill\n"; | |
729 | ||
730 | CalcBoundingBox( x, y ); | |
731 | CalcBoundingBox( x + width, y + height ); | |
732 | } | |
afce4c03 | 733 | |
ed880dd4 RR |
734 | if (m_pen.GetStyle () != wxTRANSPARENT) |
735 | { | |
736 | SetPen (m_pen); | |
afce4c03 | 737 | |
ed880dd4 RR |
738 | // Draw rectangle anticlockwise |
739 | *m_pstream << "newpath\n" | |
740 | << XLOG2DEV(x + rad) << " " << YLOG2DEV(y + rad) << " " << XLOG2DEVREL(rad) << " 90 180 arc\n" | |
741 | << XLOG2DEV(x) << " " << YLOG2DEV(y + rad) << " moveto\n" | |
742 | << XLOG2DEV(x + rad) << " " << YLOG2DEV(y + height - rad) << " " << XLOG2DEVREL(rad) << " 180 270 arc\n" | |
743 | << XLOG2DEV(x + width - rad) << " " << YLOG2DEV(y + height) << " lineto\n" | |
744 | << XLOG2DEV(x + width - rad) << " " << YLOG2DEV(y + height - rad) << " " << XLOG2DEVREL(rad) << " 270 0 arc\n" | |
745 | << XLOG2DEV(x + width) << " " << YLOG2DEV(y + rad) << " lineto\n" | |
746 | << XLOG2DEV(x + width - rad) << " " << YLOG2DEV(y + rad) << " " << XLOG2DEVREL(rad) << " 0 90 arc\n" | |
747 | << XLOG2DEV(x + rad) << " " << YLOG2DEV(y) << " lineto\n" | |
748 | << "closepath\n" | |
749 | << "stroke\n"; | |
750 | ||
751 | CalcBoundingBox( x, y ); | |
752 | CalcBoundingBox( x + width, y + height ); | |
753 | } | |
754 | } | |
755 | ||
64698f9a | 756 | void wxPostScriptDC::DoDrawEllipse (long x, long y, long width, long height) |
ed880dd4 | 757 | { |
87138c52 | 758 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 759 | |
ed880dd4 RR |
760 | if (m_brush.GetStyle () != wxTRANSPARENT) |
761 | { | |
762 | SetBrush (m_brush); | |
763 | ||
afce4c03 VZ |
764 | *m_pstream << "newpath\n" |
765 | << XLOG2DEV(x + width / 2) << " " << YLOG2DEV(y + height / 2) << " " | |
766 | << XLOG2DEV(width / 2) << " " << YLOG2DEVREL(height / 2) << " 0 360 ellipse\n" | |
ed880dd4 RR |
767 | << "fill\n"; |
768 | ||
769 | CalcBoundingBox( x - width, y - height ); | |
770 | CalcBoundingBox( x + width, y + height ); | |
771 | } | |
afce4c03 | 772 | |
ed880dd4 RR |
773 | if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT) |
774 | { | |
775 | SetPen (m_pen); | |
776 | ||
afce4c03 VZ |
777 | *m_pstream << "newpath\n" |
778 | << XLOG2DEV(x + width / 2) << " " << YLOG2DEV(y + height / 2) << " " | |
779 | << XLOG2DEV(width / 2) << " " << YLOG2DEVREL(height / 2) << " 0 360 ellipse\n" | |
ed880dd4 RR |
780 | << "stroke\n"; |
781 | ||
782 | CalcBoundingBox( x - width, y - height ); | |
783 | CalcBoundingBox( x + width, y + height ); | |
784 | } | |
785 | } | |
786 | ||
64698f9a | 787 | void wxPostScriptDC::DoDrawIcon( const wxIcon& icon, long x, long y ) |
ed880dd4 | 788 | { |
ef539066 | 789 | DrawBitmap( icon, x, y, TRUE ); |
ed880dd4 RR |
790 | } |
791 | ||
64698f9a | 792 | void wxPostScriptDC::DoDrawBitmap( const wxBitmap& bitmap, long x, long y, bool WXUNUSED(useMask) ) |
ed880dd4 | 793 | { |
87138c52 | 794 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
ef539066 RR |
795 | |
796 | if (!bitmap.Ok()) return; | |
afce4c03 | 797 | |
ef539066 | 798 | wxImage image( bitmap ); |
afce4c03 | 799 | |
ef539066 | 800 | if (!image.Ok()) return; |
afce4c03 | 801 | |
ef539066 RR |
802 | int ww = XLOG2DEVREL(image.GetWidth()); |
803 | int hh = YLOG2DEVREL(image.GetHeight()); | |
afce4c03 | 804 | |
ef539066 | 805 | image = image.Scale( ww, hh ); |
afce4c03 | 806 | |
ef539066 | 807 | if (!image.Ok()) return; |
afce4c03 | 808 | |
ef539066 RR |
809 | int xx = XLOG2DEV(x); |
810 | int yy = YLOG2DEV(y + bitmap.GetHeight()); | |
afce4c03 | 811 | |
ef539066 RR |
812 | *m_pstream << "/origstate save def\n" |
813 | << "20 dict begin\n" | |
814 | << "/pix " << ww << " string def\n" | |
815 | << "/grays " << ww << " string def\n" | |
816 | << "/npixels 0 def\n" | |
817 | << "/rgbindx 0 def\n" | |
818 | << xx << " " << yy << " translate\n" | |
819 | << ww << " " << hh << " scale\n" | |
820 | << ww << " " << hh << " 8\n" | |
821 | << "[" << ww << " 0 0 " << (-hh) << " 0 " << hh << "]\n" | |
822 | << "{currentfile pix readhexstring pop}\n" | |
823 | << "false 3 colorimage\n"; | |
afce4c03 | 824 | |
ef539066 RR |
825 | for (int j = 0; j < hh; j++) |
826 | { | |
827 | for (int i = 0; i < ww; i++) | |
828 | { | |
87138c52 | 829 | wxChar buffer[5]; |
9a6be59a VZ |
830 | buffer[2] = 0; |
831 | wxDecToHex( image.GetRed(i,j), buffer ); | |
ef539066 | 832 | *m_pstream << buffer; |
9a6be59a | 833 | wxDecToHex( image.GetGreen(i,j), buffer ); |
ef539066 | 834 | *m_pstream << buffer; |
9a6be59a | 835 | wxDecToHex( image.GetBlue(i,j), buffer ); |
ef539066 | 836 | *m_pstream << buffer; |
9a6be59a VZ |
837 | } |
838 | *m_pstream << "\n"; | |
ef539066 RR |
839 | } |
840 | ||
841 | *m_pstream << "end\n"; | |
842 | *m_pstream << "origstate restore\n"; | |
afce4c03 | 843 | |
ed880dd4 RR |
844 | } |
845 | ||
36b3b54a | 846 | void wxPostScriptDC::SetFont( const wxFont& font ) |
ed880dd4 | 847 | { |
87138c52 | 848 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 849 | |
ed880dd4 | 850 | if (!font.Ok()) return; |
afce4c03 | 851 | |
ed880dd4 | 852 | m_font = font; |
57c208c5 | 853 | |
36b3b54a RR |
854 | const char *name; |
855 | const char *style = ""; | |
856 | int Style = m_font.GetStyle(); | |
857 | int Weight = m_font.GetWeight(); | |
858 | ||
859 | switch (m_font.GetFamily ()) | |
860 | { | |
861 | case wxTELETYPE: | |
862 | case wxMODERN: | |
863 | name = "/Courier"; | |
864 | break; | |
865 | case wxSWISS: | |
866 | name = "/Helvetica"; | |
867 | break; | |
868 | case wxROMAN: | |
869 | // name = "/Times-Roman"; | |
870 | name = "/Times"; // Altered by EDZ | |
871 | break; | |
872 | case wxSCRIPT: | |
873 | name = "/Zapf-Chancery-MediumItalic"; | |
874 | Style = wxNORMAL; | |
875 | Weight = wxNORMAL; | |
876 | break; | |
877 | default: | |
878 | case wxDEFAULT: // Sans Serif Font | |
879 | name = "/LucidaSans"; | |
880 | } | |
881 | ||
882 | if (Style == wxNORMAL && (Weight == wxNORMAL || Weight == wxLIGHT)) | |
57c208c5 JS |
883 | { |
884 | if (m_font.GetFamily () == wxROMAN) | |
9a6be59a | 885 | style = "-Roman"; |
57c208c5 | 886 | else |
9a6be59a | 887 | style = ""; |
57c208c5 | 888 | } |
36b3b54a RR |
889 | else if (Style == wxNORMAL && Weight == wxBOLD) |
890 | { | |
891 | style = "-Bold"; | |
892 | } | |
893 | else if (Style == wxITALIC && (Weight == wxNORMAL || Weight == wxLIGHT)) | |
57c208c5 JS |
894 | { |
895 | if (m_font.GetFamily () == wxROMAN) | |
9a6be59a | 896 | style = "-Italic"; |
57c208c5 | 897 | else |
9a6be59a | 898 | style = "-Oblique"; |
57c208c5 | 899 | } |
36b3b54a | 900 | else if (Style == wxITALIC && Weight == wxBOLD) |
57c208c5 JS |
901 | { |
902 | if (m_font.GetFamily () == wxROMAN) | |
9a6be59a | 903 | style = "-BoldItalic"; |
57c208c5 | 904 | else |
9a6be59a | 905 | style = "-BoldOblique"; |
57c208c5 | 906 | } |
36b3b54a | 907 | else if (Style == wxSLANT && (Weight == wxNORMAL || Weight == wxLIGHT)) |
57c208c5 JS |
908 | { |
909 | if (m_font.GetFamily () == wxROMAN) | |
9a6be59a | 910 | style = "-Italic"; |
57c208c5 | 911 | else |
9a6be59a | 912 | style = "-Oblique"; |
57c208c5 | 913 | } |
36b3b54a | 914 | else if (Style == wxSLANT && Weight == wxBOLD) |
57c208c5 JS |
915 | { |
916 | if (m_font.GetFamily () == wxROMAN) | |
9a6be59a | 917 | style = "-BoldItalic"; |
57c208c5 | 918 | else |
9a6be59a | 919 | style = "-BoldOblique"; |
57c208c5 | 920 | } |
36b3b54a RR |
921 | else |
922 | { | |
923 | style = ""; | |
924 | } | |
57c208c5 | 925 | |
36b3b54a RR |
926 | char buf[100]; |
927 | strcpy (buf, name); | |
928 | strcat (buf, style); | |
afce4c03 | 929 | |
36b3b54a RR |
930 | *m_pstream << buf << " reencodeISO def\n"; |
931 | *m_pstream << buf << " findfont\n"; | |
932 | *m_pstream << YLOG2DEVREL(m_font.GetPointSize()) << " scalefont setfont\n"; | |
ed880dd4 RR |
933 | } |
934 | ||
935 | void wxPostScriptDC::SetPen( const wxPen& pen ) | |
936 | { | |
87138c52 | 937 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 938 | |
ed880dd4 | 939 | if (!pen.Ok()) return; |
afce4c03 | 940 | |
ed880dd4 RR |
941 | int oldStyle = m_pen.GetStyle(); |
942 | ||
943 | m_pen = pen; | |
944 | ||
945 | *m_pstream << XLOG2DEVREL(m_pen.GetWidth()) << " setlinewidth\n"; | |
946 | ||
947 | /* | |
948 | Line style - WRONG: 2nd arg is OFFSET | |
afce4c03 | 949 | |
ed880dd4 RR |
950 | Here, I'm afraid you do not conceive meaning of parameters of 'setdash' |
951 | operator correctly. You should look-up this in the Red Book: the 2nd parame- | |
952 | ter is not number of values in the array of the first one, but an offset | |
953 | into this description of the pattern. I mean a real *offset* not index | |
954 | into array. I.e. If the command is [3 4] 1 setdash is used, then there | |
955 | will be first black line *2* units long, then space 4 units, then the | |
956 | pattern of *3* units black, 4 units space will be repeated. | |
957 | */ | |
958 | ||
959 | static const char *dotted = "[2 5] 2"; | |
960 | static const char *short_dashed = "[4 4] 2"; | |
961 | static const char *long_dashed = "[4 8] 2"; | |
962 | static const char *dotted_dashed = "[6 6 2 6] 4"; | |
963 | ||
964 | const char *psdash = (char *) NULL; | |
965 | switch (m_pen.GetStyle ()) | |
966 | { | |
967 | case wxDOT: psdash = dotted; break; | |
968 | case wxSHORT_DASH: psdash = short_dashed; break; | |
969 | case wxLONG_DASH: psdash = long_dashed; break; | |
970 | case wxDOT_DASH: psdash = dotted_dashed; break; | |
971 | case wxSOLID: | |
972 | case wxTRANSPARENT: | |
973 | default: psdash = "[] 0"; break; | |
974 | } | |
afce4c03 | 975 | |
ed880dd4 RR |
976 | if (oldStyle != m_pen.GetStyle()) |
977 | { | |
978 | *m_pstream << psdash << " setdash\n"; | |
979 | } | |
980 | ||
981 | // Line colour | |
982 | unsigned char red = m_pen.GetColour().Red(); | |
983 | unsigned char blue = m_pen.GetColour().Blue(); | |
984 | unsigned char green = m_pen.GetColour().Green(); | |
985 | ||
986 | if (!m_colour) | |
987 | { | |
988 | // Anything not white is black | |
989 | if (!(red == (unsigned char) 255 && blue == (unsigned char) 255 | |
9a6be59a VZ |
990 | && green == (unsigned char) 255)) |
991 | { | |
992 | red = (unsigned char) 0; | |
993 | green = (unsigned char) 0; | |
994 | blue = (unsigned char) 0; | |
995 | } | |
afce4c03 | 996 | |
9a6be59a | 997 | // setgray here ? |
ed880dd4 RR |
998 | } |
999 | ||
1000 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) | |
1001 | { | |
3c1b65a4 RR |
1002 | float redPS = (float)(red) / 255.0; |
1003 | float bluePS = (float)(blue) / 255.0; | |
1004 | float greenPS = (float)(green) / 255.0; | |
ed880dd4 RR |
1005 | *m_pstream << redPS << " " << greenPS << " " << bluePS << " setrgbcolor\n"; |
1006 | ||
1007 | m_currentRed = red; | |
1008 | m_currentBlue = blue; | |
1009 | m_currentGreen = green; | |
1010 | } | |
1011 | } | |
1012 | ||
1013 | void wxPostScriptDC::SetBrush( const wxBrush& brush ) | |
1014 | { | |
87138c52 | 1015 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1016 | |
ed880dd4 | 1017 | if (!brush.Ok()) return; |
afce4c03 | 1018 | |
ed880dd4 RR |
1019 | m_brush = brush; |
1020 | ||
1021 | // Brush colour | |
3c1b65a4 RR |
1022 | unsigned char red = m_brush.GetColour().Red(); |
1023 | unsigned char blue = m_brush.GetColour().Blue(); | |
1024 | unsigned char green = m_brush.GetColour().Green(); | |
ed880dd4 RR |
1025 | |
1026 | if (!m_colour) | |
1027 | { | |
1028 | // Anything not black is white | |
1029 | if (!(red == (unsigned char) 0 && blue == (unsigned char) 0 | |
9a6be59a VZ |
1030 | && green == (unsigned char) 0)) |
1031 | { | |
1032 | red = (unsigned char) 255; | |
1033 | green = (unsigned char) 255; | |
1034 | blue = (unsigned char) 255; | |
1035 | } | |
afce4c03 | 1036 | |
9a6be59a | 1037 | // setgray here ? |
ed880dd4 RR |
1038 | } |
1039 | ||
1040 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) | |
1041 | { | |
3c1b65a4 RR |
1042 | float redPS = (float)(red) / 255.0; |
1043 | float bluePS = (float)(blue) / 255.0; | |
1044 | float greenPS = (float)(green) / 255.0; | |
ed880dd4 RR |
1045 | *m_pstream << redPS << " " << greenPS << " " << bluePS << " setrgbcolor\n"; |
1046 | m_currentRed = red; | |
1047 | m_currentBlue = blue; | |
1048 | m_currentGreen = green; | |
1049 | } | |
1050 | } | |
1051 | ||
64698f9a | 1052 | void wxPostScriptDC::DoDrawText( const wxString& text, long x, long y ) |
ed880dd4 | 1053 | { |
87138c52 | 1054 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1055 | |
ed880dd4 RR |
1056 | SetFont( m_font ); |
1057 | ||
1058 | if (m_textForegroundColour.Ok ()) | |
1059 | { | |
1060 | unsigned char red = m_textForegroundColour.Red (); | |
1061 | unsigned char blue = m_textForegroundColour.Blue (); | |
1062 | unsigned char green = m_textForegroundColour.Green (); | |
1063 | ||
1064 | if (!m_colour) | |
9a6be59a VZ |
1065 | { |
1066 | // Anything not white is black | |
1067 | if (!(red == (unsigned char) 255 && blue == (unsigned char) 255 | |
1068 | && green == (unsigned char) 255)) | |
1069 | { | |
1070 | red = (unsigned char) 0; | |
1071 | green = (unsigned char) 0; | |
1072 | blue = (unsigned char) 0; | |
1073 | } | |
1074 | } | |
afce4c03 | 1075 | |
9a6be59a | 1076 | // maybe setgray here ? |
afce4c03 | 1077 | |
ed880dd4 RR |
1078 | if (!(red == m_currentRed && green == m_currentGreen && blue == m_currentBlue)) |
1079 | { | |
3c1b65a4 RR |
1080 | float redPS = (float)(red) / 255.0; |
1081 | float bluePS = (float)(blue) / 255.0; | |
1082 | float greenPS = (float)(green) / 255.0; | |
ed880dd4 RR |
1083 | *m_pstream << redPS << " " << greenPS << " " << bluePS << " setrgbcolor\n"; |
1084 | ||
1085 | m_currentRed = red; | |
1086 | m_currentBlue = blue; | |
1087 | m_currentGreen = green; | |
1088 | } | |
1089 | } | |
1090 | ||
1091 | int size = m_font.GetPointSize(); | |
1092 | ||
1093 | long by = y + (long)floor( float(size) * 2.0 / 3.0 ); // approximate baseline | |
1094 | *m_pstream << XLOG2DEV(x) << " " << YLOG2DEV(by) << " moveto\n"; | |
afce4c03 | 1095 | |
ed880dd4 | 1096 | *m_pstream << "("; |
9626e0bf | 1097 | const wxWX2MBbuf textbuf = text.mb_str(); |
87138c52 | 1098 | int len = strlen (textbuf); |
ed880dd4 RR |
1099 | int i; |
1100 | for (i = 0; i < len; i++) | |
1101 | { | |
87138c52 | 1102 | int c = (unsigned char) textbuf[i]; |
ed880dd4 RR |
1103 | if ( c == ')' || c == '(' || c == '\\') |
1104 | { | |
1105 | *m_pstream << "\\" << (char) c; | |
1106 | } | |
1107 | else if ( c >= 128 ) | |
1108 | { | |
1109 | // Cope with character codes > 127 | |
1110 | char tmp[5]; | |
1111 | sprintf(tmp, "\\%o", c); | |
1112 | *m_pstream << tmp; | |
1113 | } | |
1114 | else | |
1115 | *m_pstream << (char) c; | |
1116 | } | |
1117 | ||
1118 | *m_pstream << ")" << " show\n"; | |
1119 | ||
1120 | if (m_font.GetUnderlined()) | |
1121 | { | |
1122 | long uy = (long)(y + size - m_underlinePosition); | |
1123 | long w, h; | |
1124 | GetTextExtent(text, &w, &h); | |
afce4c03 | 1125 | |
ed880dd4 RR |
1126 | *m_pstream << "gsave " << XLOG2DEV(x) << " " << YLOG2DEV(uy) |
1127 | << " moveto\n" | |
1128 | << (long)m_underlineThickness << " setlinewidth " | |
1129 | << XLOG2DEV(x + w) << " " << YLOG2DEV(uy) | |
1130 | << " lineto stroke grestore\n"; | |
1131 | } | |
afce4c03 | 1132 | |
ed880dd4 RR |
1133 | CalcBoundingBox( x, y ); |
1134 | CalcBoundingBox( x + size * text.Length() * 2/3 , y ); | |
1135 | } | |
1136 | ||
1137 | ||
1138 | void wxPostScriptDC::SetBackground (const wxBrush& brush) | |
1139 | { | |
1140 | m_backgroundBrush = brush; | |
1141 | } | |
1142 | ||
1143 | void wxPostScriptDC::SetLogicalFunction (int WXUNUSED(function)) | |
1144 | { | |
87138c52 | 1145 | wxFAIL_MSG( _T("wxPostScriptDC::SetLogicalFunction not implemented.") ); |
ed880dd4 RR |
1146 | } |
1147 | ||
64698f9a | 1148 | void wxPostScriptDC::DoDrawSpline( wxList *points ) |
ed880dd4 | 1149 | { |
87138c52 | 1150 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1151 | |
ed880dd4 RR |
1152 | SetPen( m_pen ); |
1153 | ||
1154 | double a, b, c, d, x1, y1, x2, y2, x3, y3; | |
1155 | wxPoint *p, *q; | |
1156 | ||
1157 | wxNode *node = points->First(); | |
1158 | p = (wxPoint *)node->Data(); | |
afce4c03 | 1159 | x1 = p->x; |
ed880dd4 RR |
1160 | y1 = p->y; |
1161 | ||
1162 | node = node->Next(); | |
1163 | p = (wxPoint *)node->Data(); | |
afce4c03 | 1164 | c = p->x; |
ed880dd4 RR |
1165 | d = p->y; |
1166 | x3 = a = (double)(x1 + c) / 2; | |
1167 | y3 = b = (double)(y1 + d) / 2; | |
1168 | ||
afce4c03 VZ |
1169 | *m_pstream << "newpath " |
1170 | << XLOG2DEV((long)x1) << " " << YLOG2DEV((long)y1) << " moveto " | |
9a6be59a | 1171 | << XLOG2DEV((long)x3) << " " << YLOG2DEV((long)y3) << " lineto\n"; |
afce4c03 | 1172 | |
ed880dd4 RR |
1173 | CalcBoundingBox( (long)x1, (long)y1 ); |
1174 | CalcBoundingBox( (long)x3, (long)y3 ); | |
1175 | ||
1176 | while ((node = node->Next()) != NULL) | |
1177 | { | |
1178 | q = (wxPoint *)node->Data(); | |
1179 | ||
afce4c03 | 1180 | x1 = x3; |
9a6be59a | 1181 | y1 = y3; |
afce4c03 | 1182 | x2 = c; |
9a6be59a | 1183 | y2 = d; |
afce4c03 | 1184 | c = q->x; |
9a6be59a | 1185 | d = q->y; |
ed880dd4 RR |
1186 | x3 = (double)(x2 + c) / 2; |
1187 | y3 = (double)(y2 + d) / 2; | |
afce4c03 | 1188 | *m_pstream << XLOG2DEV((long)x1) << " " << YLOG2DEV((long)y1) << " " |
9a6be59a | 1189 | << XLOG2DEV((long)x2) << " " << YLOG2DEV((long)y2) << " " |
ed880dd4 RR |
1190 | << XLOG2DEV((long)x3) << " " << YLOG2DEV((long)y3) << " DrawSplineSection\n"; |
1191 | ||
1192 | CalcBoundingBox( (long)x1, (long)y1 ); | |
1193 | CalcBoundingBox( (long)x3, (long)y3 ); | |
1194 | } | |
afce4c03 | 1195 | |
ed880dd4 RR |
1196 | /* |
1197 | At this point, (x2,y2) and (c,d) are the position of the | |
1198 | next-to-last and last point respectively, in the point list | |
1199 | */ | |
1200 | ||
1201 | *m_pstream << XLOG2DEV((long)c) << " " << YLOG2DEV((long)d) << " lineto stroke\n"; | |
1202 | } | |
1203 | ||
64698f9a | 1204 | long wxPostScriptDC::GetCharWidth() const |
ed880dd4 RR |
1205 | { |
1206 | // Chris Breeze: reasonable approximation using wxMODERN/Courier | |
1207 | return (long) (GetCharHeight() * 72.0 / 120.0); | |
1208 | } | |
1209 | ||
1210 | ||
1211 | void wxPostScriptDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) | |
1212 | { | |
87138c52 | 1213 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1214 | |
ed880dd4 RR |
1215 | m_signX = (xLeftRight ? 1 : -1); |
1216 | m_signY = (yBottomUp ? 1 : -1); | |
afce4c03 | 1217 | |
9a6be59a VZ |
1218 | // FIXME there is no such function in MSW |
1219 | #ifndef __WXMSW__ | |
ed880dd4 | 1220 | ComputeScaleAndOrigin(); |
9a6be59a | 1221 | #endif |
ed880dd4 RR |
1222 | } |
1223 | ||
1224 | void wxPostScriptDC::SetDeviceOrigin( long x, long y ) | |
1225 | { | |
87138c52 | 1226 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1227 | |
4bc67cc5 RR |
1228 | int h = 0; |
1229 | int w = 0; | |
1230 | GetSize( &w, &h ); | |
afce4c03 | 1231 | |
4bc67cc5 | 1232 | wxDC::SetDeviceOrigin( x, h-y ); |
ed880dd4 RR |
1233 | } |
1234 | ||
4e4ea166 | 1235 | void wxPostScriptDC::DoGetSize(int* width, int* height) const |
ed880dd4 | 1236 | { |
7bcb11d3 | 1237 | wxPaperSize id = m_printData.GetPaperId(); |
ed880dd4 | 1238 | |
7bcb11d3 | 1239 | wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(id); |
afce4c03 | 1240 | |
7bcb11d3 | 1241 | if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); |
afce4c03 | 1242 | |
ed880dd4 RR |
1243 | if (paper) |
1244 | { | |
7bcb11d3 JS |
1245 | if (width) *width = paper->GetSizeDeviceUnits().x; |
1246 | if (height) *height = paper->GetSizeDeviceUnits().y; | |
ed880dd4 RR |
1247 | } |
1248 | else | |
1249 | { | |
4bc67cc5 RR |
1250 | if (width) *width = 595; |
1251 | if (height) *height = 842; | |
ed880dd4 RR |
1252 | } |
1253 | } | |
1254 | ||
4e4ea166 | 1255 | void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const |
ed880dd4 | 1256 | { |
7bcb11d3 JS |
1257 | wxPaperSize id = m_printData.GetPaperId(); |
1258 | ||
1259 | wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(id); | |
afce4c03 | 1260 | |
7bcb11d3 JS |
1261 | if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); |
1262 | ||
1263 | if (paper) | |
ed880dd4 | 1264 | { |
7bcb11d3 JS |
1265 | if (width) *width = paper->GetWidth() / 10; |
1266 | if (height) *height = paper->GetHeight() / 10; | |
ed880dd4 RR |
1267 | } |
1268 | else | |
1269 | { | |
7bcb11d3 JS |
1270 | if (width) *width = 210; |
1271 | if (height) *height = 297; | |
ed880dd4 | 1272 | } |
7bcb11d3 JS |
1273 | } |
1274 | ||
1275 | // Resolution in pixels per logical inch | |
1276 | wxSize wxPostScriptDC::GetPPI(void) const | |
1277 | { | |
1278 | return wxSize(72, 72); | |
1279 | } | |
ed880dd4 | 1280 | |
7bcb11d3 JS |
1281 | |
1282 | bool wxPostScriptDC::StartDoc (const wxString& message) | |
1283 | { | |
87138c52 | 1284 | wxCHECK_MSG( m_ok, FALSE, _T("invalid postscript dc") ); |
7bcb11d3 JS |
1285 | |
1286 | if (m_printData.GetFilename() == "") | |
1287 | { | |
1288 | wxString filename = wxGetTempFileName("ps"); | |
1289 | m_printData.SetFilename(filename); | |
1290 | ||
1291 | m_ok = TRUE; | |
1292 | } | |
1293 | ||
87138c52 | 1294 | m_pstream = new ofstream (m_printData.GetFilename().fn_str()); |
afce4c03 | 1295 | |
ed880dd4 RR |
1296 | if (!m_pstream || !m_pstream->good()) |
1297 | { | |
7bcb11d3 JS |
1298 | wxMessageBox (_("Cannot open file!"), _("Error"), wxOK); |
1299 | m_ok = FALSE; | |
1300 | return FALSE; | |
ed880dd4 | 1301 | } |
afce4c03 | 1302 | |
ed880dd4 RR |
1303 | m_ok = TRUE; |
1304 | ||
1305 | SetBrush( *wxBLACK_BRUSH ); | |
1306 | SetPen( *wxBLACK_PEN ); | |
1307 | SetBackground( *wxWHITE_BRUSH ); | |
1308 | SetTextForeground( *wxBLACK ); | |
1309 | ||
1310 | // set origin according to paper size | |
1311 | SetDeviceOrigin( 0,0 ); | |
afce4c03 | 1312 | |
ed880dd4 RR |
1313 | wxPageNumber = 1; |
1314 | m_pageNumber = 1; | |
1315 | m_title = message; | |
1316 | return TRUE; | |
1317 | } | |
1318 | ||
1319 | void wxPostScriptDC::EndDoc () | |
1320 | { | |
87138c52 | 1321 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1322 | |
ed880dd4 RR |
1323 | if (m_clipping) |
1324 | { | |
1325 | m_clipping = FALSE; | |
1326 | *m_pstream << "grestore\n"; | |
1327 | } | |
1328 | ||
1329 | if (m_pstream) | |
1330 | { | |
1331 | delete m_pstream; | |
1332 | m_pstream = (ofstream *) NULL; | |
1333 | } | |
1334 | ||
87138c52 | 1335 | wxChar *header_file = wxGetTempFileName("ps"); |
afce4c03 | 1336 | |
dcf924a3 | 1337 | m_pstream = new ofstream( wxConvCurrent->cWX2MB(header_file) ); |
ed880dd4 | 1338 | |
9a6be59a | 1339 | *m_pstream << "%!PS-Adobe-2.0\n"; /* PostScript magic strings */ |
87138c52 | 1340 | *m_pstream << "%%Title: " << m_title.mb_str() << "\n"; |
ed880dd4 | 1341 | *m_pstream << "%%Creator: " << wxTheApp->argv[0] << "\n"; |
4ca9b362 | 1342 | *m_pstream << "%%CreationDate: " << wxNow().mb_str() << "\n"; |
ed880dd4 | 1343 | |
87138c52 | 1344 | wxChar userID[256]; |
ed880dd4 RR |
1345 | if ( wxGetEmailAddress(userID, sizeof(userID)) ) |
1346 | { | |
dcf924a3 | 1347 | *m_pstream << "%%For: " << MBSTRINGCAST wxConvCurrent->cWX2MB(userID); |
87138c52 | 1348 | wxChar userName[245]; |
ed880dd4 | 1349 | if (wxGetUserName(userName, sizeof(userName))) |
dcf924a3 | 1350 | *m_pstream << " (" << MBSTRINGCAST wxConvCurrent->cWX2MB(userName) << ")"; |
ed880dd4 RR |
1351 | *m_pstream << "\n"; |
1352 | } | |
1353 | else if ( wxGetUserName(userID, sizeof(userID)) ) | |
1354 | { | |
dcf924a3 | 1355 | *m_pstream << "%%For: " << MBSTRINGCAST wxConvCurrent->cWX2MB(userID) << "\n"; |
ed880dd4 RR |
1356 | } |
1357 | ||
1358 | // THE FOLLOWING HAS BEEN CONTRIBUTED BY Andy Fyfe <andy@hyperparallel.com> | |
1359 | ||
1360 | long wx_printer_translate_x, wx_printer_translate_y; | |
1361 | double wx_printer_scale_x, wx_printer_scale_y; | |
ed880dd4 | 1362 | |
7bcb11d3 JS |
1363 | wx_printer_translate_x = m_printData.GetPrinterTranslateX(); |
1364 | wx_printer_translate_y = m_printData.GetPrinterTranslateY(); | |
1365 | ||
1366 | wx_printer_scale_x = m_printData.GetPrinterScaleX(); | |
1367 | wx_printer_scale_y = m_printData.GetPrinterScaleY(); | |
1368 | ||
1369 | if (m_printData.GetOrientation() == wxLANDSCAPE) | |
ed880dd4 | 1370 | { |
7bcb11d3 | 1371 | *m_pstream << "%%Orientation: Landscape\n"; |
ed880dd4 RR |
1372 | } |
1373 | else | |
1374 | { | |
1375 | *m_pstream << "%%Orientation: Portrait\n"; | |
1376 | } | |
1377 | ||
1378 | // Compute the bounding box. Note that it is in the default user | |
1379 | // coordinate system, thus we have to convert the values. | |
1380 | long llx = (long) ((XLOG2DEV(m_minX)+wx_printer_translate_x)*wx_printer_scale_x); | |
1381 | long lly = (long) ((YLOG2DEV(m_minY)+wx_printer_translate_y)*wx_printer_scale_y); | |
1382 | long urx = (long) ((XLOG2DEV(m_maxX)+wx_printer_translate_x)*wx_printer_scale_x); | |
1383 | long ury = (long) ((YLOG2DEV(m_maxY)+wx_printer_translate_y)*wx_printer_scale_y); | |
1384 | ||
1385 | // If we're landscape, our sense of "x" and "y" is reversed. | |
7bcb11d3 | 1386 | if (m_printData.GetOrientation() == wxLANDSCAPE) |
ed880dd4 RR |
1387 | { |
1388 | long tmp; | |
1389 | tmp = llx; llx = lly; lly = tmp; | |
1390 | tmp = urx; urx = ury; ury = tmp; | |
1391 | ||
1392 | // We need either the two lines that follow, or we need to subtract | |
1393 | // min_x from real_translate_y, which is commented out below. | |
1394 | llx = llx - (long)(m_minX*wx_printer_scale_y); | |
1395 | urx = urx - (long)(m_minX*wx_printer_scale_y); | |
1396 | } | |
1397 | ||
1398 | // The Adobe specifications call for integers; we round as to make | |
1399 | // the bounding larger. | |
1400 | *m_pstream << "%%BoundingBox: " | |
1401 | << floor((double)llx) << " " << floor((double)lly) << " " | |
1402 | << ceil((double)urx) << " " << ceil((double)ury) << "\n"; | |
1403 | *m_pstream << "%%Pages: " << (wxPageNumber - 1) << "\n"; | |
1404 | *m_pstream << "%%EndComments\n\n"; | |
1405 | ||
1406 | // To check the correctness of the bounding box, postscript commands | |
1407 | // to draw a box corresponding to the bounding box are generated below. | |
1408 | // But since we typically don't want to print such a box, the postscript | |
1409 | // commands are generated within comments. These lines appear before any | |
1410 | // adjustment of scale, rotation, or translation, and hence are in the | |
1411 | // default user coordinates. | |
1412 | *m_pstream << "% newpath\n"; | |
1413 | *m_pstream << "% " << llx << " " << lly << " moveto\n"; | |
1414 | *m_pstream << "% " << urx << " " << lly << " lineto\n"; | |
1415 | *m_pstream << "% " << urx << " " << ury << " lineto\n"; | |
1416 | *m_pstream << "% " << llx << " " << ury << " lineto closepath stroke\n"; | |
1417 | ||
1418 | *m_pstream << "%%BeginProlog\n"; | |
1419 | *m_pstream << wxPostScriptHeaderEllipse; | |
1420 | *m_pstream << wxPostScriptHeaderEllipticArc; | |
ef539066 | 1421 | *m_pstream << wxPostScriptHeaderColourImage; |
ed880dd4 RR |
1422 | *m_pstream << wxPostScriptHeaderReencodeISO1; |
1423 | *m_pstream << wxPostScriptHeaderReencodeISO2; | |
1424 | ||
1425 | if (wxPostScriptHeaderSpline) | |
1426 | *m_pstream << wxPostScriptHeaderSpline; | |
1427 | *m_pstream << "%%EndProlog\n"; | |
1428 | ||
1429 | delete m_pstream; | |
1430 | m_pstream = (ofstream *) NULL; | |
1431 | ||
87138c52 | 1432 | wxChar *tmp_file = wxGetTempFileName("ps"); |
ed880dd4 RR |
1433 | |
1434 | // Paste header Before wx_printer_file | |
7bcb11d3 | 1435 | wxConcatFiles (header_file, m_printData.GetFilename(), tmp_file); |
ed880dd4 | 1436 | wxRemoveFile (header_file); |
7bcb11d3 JS |
1437 | wxRemoveFile (m_printData.GetFilename()); |
1438 | wxRenameFile(tmp_file, m_printData.GetFilename()); | |
ed880dd4 RR |
1439 | |
1440 | #if defined(__X__) || defined(__WXGTK__) | |
1441 | if (m_ok) | |
1442 | { | |
7bcb11d3 JS |
1443 | wxString previewCommand(m_printData.GetPreviewCommand()); |
1444 | wxString printerCommand(m_printData.GetPrinterCommand()); | |
1445 | wxString printerOptions(m_printData.GetPrinterOptions()); | |
1446 | wxString filename(m_printData.GetFilename()); | |
1447 | ||
1448 | switch (m_printData.GetPrintMode()) { | |
1449 | ||
1450 | case wxPRINT_MODE_PREVIEW: | |
9a6be59a | 1451 | { |
87138c52 OK |
1452 | wxChar *argv[3]; |
1453 | argv[0] = WXSTRINGCAST previewCommand; | |
1454 | argv[1] = WXSTRINGCAST filename; | |
1455 | argv[2] = (wxChar*) NULL; | |
7bcb11d3 JS |
1456 | wxExecute (argv, TRUE); |
1457 | wxRemoveFile(m_printData.GetFilename()); | |
9a6be59a VZ |
1458 | } |
1459 | break; | |
ed880dd4 | 1460 | |
7bcb11d3 | 1461 | case wxPRINT_MODE_PRINTER: |
9a6be59a | 1462 | { |
87138c52 | 1463 | wxChar *argv[4]; |
ed880dd4 | 1464 | int argc = 0; |
87138c52 | 1465 | argv[argc++] = WXSTRINGCAST printerCommand; |
ed880dd4 RR |
1466 | |
1467 | // !SM! If we simply assign to argv[1] here, if printer options | |
1468 | // are blank, we get an annoying and confusing message from lpr. | |
87138c52 | 1469 | wxChar * opts = WXSTRINGCAST printerOptions; |
ed880dd4 RR |
1470 | if (opts && *opts) |
1471 | argv[argc++] = opts; | |
1472 | ||
87138c52 OK |
1473 | argv[argc++] = WXSTRINGCAST filename; |
1474 | argv[argc++] = (wxChar *) NULL; | |
7bcb11d3 JS |
1475 | wxExecute (argv, TRUE); |
1476 | wxRemoveFile(filename); | |
9a6be59a VZ |
1477 | } |
1478 | break; | |
ed880dd4 | 1479 | |
7bcb11d3 JS |
1480 | case wxPRINT_MODE_FILE: |
1481 | case wxPRINT_MODE_NONE: | |
9a6be59a VZ |
1482 | break; |
1483 | } | |
ed880dd4 RR |
1484 | } |
1485 | #endif | |
1486 | } | |
1487 | ||
1488 | void wxPostScriptDC::StartPage () | |
1489 | { | |
87138c52 | 1490 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1491 | |
ed880dd4 | 1492 | *m_pstream << "%%Page: " << (wxPageNumber++) << "\n"; |
afce4c03 | 1493 | |
ed880dd4 RR |
1494 | // *m_pstream << "matrix currentmatrix\n"; |
1495 | ||
1496 | // Added by Chris Breeze | |
1497 | ||
9a6be59a VZ |
1498 | // Each page starts with an "initgraphics" which resets the |
1499 | // transformation and so we need to reset the origin | |
1500 | // (and rotate the page for landscape printing) | |
afce4c03 | 1501 | |
ed880dd4 | 1502 | /* |
9a6be59a VZ |
1503 | m_scaleFactor = 1.0; |
1504 | m_logicalOriginX = 0; | |
1505 | m_logicalOriginY = 0; | |
ed880dd4 | 1506 | */ |
afce4c03 VZ |
1507 | // Output scaling |
1508 | long translate_x, translate_y; | |
1509 | double scale_x, scale_y; | |
afce4c03 | 1510 | |
7bcb11d3 JS |
1511 | translate_x = m_printData.GetPrinterTranslateX(); |
1512 | translate_y = m_printData.GetPrinterTranslateY(); | |
1513 | ||
1514 | scale_x = m_printData.GetPrinterScaleX(); | |
1515 | scale_y = m_printData.GetPrinterScaleY(); | |
1516 | ||
1517 | if (m_printData.GetOrientation() == wxLANDSCAPE) | |
afce4c03 VZ |
1518 | { |
1519 | translate_y -= m_maxY; | |
1520 | *m_pstream << "90 rotate\n"; | |
1521 | } | |
1522 | ||
1523 | *m_pstream << scale_x << " " << scale_y << " scale\n"; | |
1524 | *m_pstream << translate_x << " " << translate_y << " translate\n"; | |
ed880dd4 RR |
1525 | } |
1526 | ||
1527 | void wxPostScriptDC::EndPage () | |
1528 | { | |
87138c52 | 1529 | wxCHECK_RET( m_ok && m_pstream, _T("invalid postscript dc") ); |
afce4c03 | 1530 | |
ed880dd4 RR |
1531 | *m_pstream << "showpage\n"; |
1532 | } | |
1533 | ||
64698f9a | 1534 | bool wxPostScriptDC::DoBlit( long xdest, long ydest, |
ea6f44b5 | 1535 | long fwidth, long fheight, |
afce4c03 VZ |
1536 | wxDC *source, |
1537 | long xsrc, long ysrc, | |
45b776d4 | 1538 | int rop, bool WXUNUSED(useMask) ) |
ed880dd4 | 1539 | { |
87138c52 | 1540 | wxCHECK_MSG( m_ok && m_pstream, FALSE, _T("invalid postscript dc") ); |
afce4c03 | 1541 | |
87138c52 | 1542 | wxCHECK_MSG( source, FALSE, _T("invalid source dc") ); |
afce4c03 | 1543 | |
342b6a2f | 1544 | /* blit into a bitmap */ |
afce4c03 VZ |
1545 | |
1546 | wxBitmap bitmap( (int)fwidth, (int)fheight ); | |
45b776d4 JS |
1547 | wxMemoryDC memDC; |
1548 | memDC.SelectObject(bitmap); | |
342b6a2f | 1549 | memDC.Blit(0, 0, fwidth, fheight, source, xsrc, ysrc, rop); /* TODO: Blit transparently? */ |
45b776d4 | 1550 | memDC.SelectObject(wxNullBitmap); |
ea6f44b5 RR |
1551 | |
1552 | /* draw bitmap. scaling and positioning is done there */ | |
1553 | ||
1554 | DrawBitmap( bitmap, xdest, ydest ); | |
afce4c03 | 1555 | |
ed880dd4 RR |
1556 | return TRUE; |
1557 | } | |
1558 | ||
64698f9a | 1559 | long wxPostScriptDC::GetCharHeight() const |
ed880dd4 RR |
1560 | { |
1561 | if (m_font.Ok()) | |
1562 | return m_font.GetPointSize(); | |
1563 | else | |
1564 | return 12; | |
1565 | } | |
1566 | ||
342b6a2f | 1567 | void wxPostScriptDC::GetTextExtent( const wxString& string, long *x, long *y, |
64698f9a | 1568 | long *descent, long *externalLeading, wxFont *theFont ) const |
ed880dd4 | 1569 | { |
36b3b54a | 1570 | wxFont *fontToUse = theFont; |
afce4c03 | 1571 | |
36b3b54a RR |
1572 | if (!fontToUse) fontToUse = (wxFont*) &m_font; |
1573 | ||
87138c52 OK |
1574 | wxCHECK_RET( fontToUse, _T("GetTextExtent: no font defined") ); |
1575 | wxCHECK_RET( x, _T("GetTextExtent: x == NULL") ); | |
1576 | wxCHECK_RET( y, _T("GetTextExtent: y == NULL") ); | |
1577 | ||
9626e0bf | 1578 | const wxWX2MBbuf strbuf = string.mb_str(); |
ed880dd4 RR |
1579 | |
1580 | #if !USE_AFM_FOR_POSTSCRIPT | |
36b3b54a RR |
1581 | /* Provide a VERY rough estimate (avoid using it). |
1582 | * Produces accurate results for mono-spaced font | |
1583 | * such as Courier (aka wxMODERN) */ | |
afce4c03 | 1584 | |
9a6be59a VZ |
1585 | int height = 12; |
1586 | if (fontToUse) | |
1587 | { | |
afce4c03 | 1588 | height = fontToUse->GetPointSize(); |
9a6be59a | 1589 | } |
87138c52 | 1590 | *x = strlen (strbuf) * height * 72 / 120; |
afce4c03 | 1591 | *y = (long) (height * 1.32); /* allow for descender */ |
36b3b54a RR |
1592 | if (descent) *descent = 0; |
1593 | if (externalLeading) *externalLeading = 0; | |
ed880dd4 | 1594 | #else |
ed880dd4 | 1595 | |
afce4c03 VZ |
1596 | /* method for calculating string widths in postscript: |
1597 | / read in the AFM (adobe font metrics) file for the | |
1598 | / actual font, parse it and extract the character widths | |
1599 | / and also the descender. this may be improved, but for now | |
1600 | / it works well. the AFM file is only read in if the | |
1601 | / font is changed. this may be chached in the future. | |
1602 | / calls to GetTextExtent with the font unchanged are rather | |
1603 | / efficient!!! | |
1604 | / | |
1605 | / for each font and style used there is an AFM file necessary. | |
1606 | / currently i have only files for the roman font family. | |
1607 | / I try to get files for the other ones! | |
1608 | / | |
1609 | / CAVE: the size of the string is currently always calculated | |
1610 | / in 'points' (1/72 of an inch). this should later on be | |
1611 | / changed to depend on the mapping mode. | |
1612 | / CAVE: the path to the AFM files must be set before calling this | |
1613 | / function. this is usually done by a call like the following: | |
1614 | / wxSetAFMPath("d:\\wxw161\\afm\\"); | |
1615 | / | |
1616 | / example: | |
1617 | / | |
1618 | / wxPostScriptDC dc(NULL, TRUE); | |
1619 | / if (dc.Ok()){ | |
1620 | / wxSetAFMPath("d:\\wxw161\\afm\\"); | |
1621 | / dc.StartDoc("Test"); | |
1622 | / dc.StartPage(); | |
1623 | / long w,h; | |
1624 | / dc.SetFont(new wxFont(10, wxROMAN, wxNORMAL, wxNORMAL)); | |
1625 | / dc.GetTextExtent("Hallo",&w,&h); | |
1626 | / dc.EndPage(); | |
1627 | / dc.EndDoc(); | |
1628 | / } | |
1629 | / | |
1630 | / by steve (stefan.hammes@urz.uni-heidelberg.de) | |
1631 | / created: 10.09.94 | |
1632 | / updated: 14.05.95 */ | |
36b3b54a RR |
1633 | |
1634 | /* these static vars are for storing the state between calls */ | |
1635 | static int lastFamily= INT_MIN; | |
1636 | static int lastSize= INT_MIN; | |
1637 | static int lastStyle= INT_MIN; | |
1638 | static int lastWeight= INT_MIN; | |
1639 | static int lastDescender = INT_MIN; | |
1640 | static int lastWidths[256]; /* widths of the characters */ | |
1641 | ||
1642 | /* get actual parameters */ | |
1643 | const int Family = fontToUse->GetFamily(); | |
1644 | const int Size = fontToUse->GetPointSize(); | |
1645 | const int Style = fontToUse->GetStyle(); | |
1646 | const int Weight = fontToUse->GetWeight(); | |
1647 | ||
1648 | /* if we have another font, read the font-metrics */ | |
1649 | if (Family!=lastFamily || Size!=lastSize || Style!=lastStyle || Weight!=lastWeight) | |
1650 | { | |
1651 | /* store actual values */ | |
1652 | lastFamily = Family; | |
1653 | lastSize = Size; | |
1654 | lastStyle = Style; | |
1655 | lastWeight = Weight; | |
1656 | ||
1657 | char *name = (char*) NULL; | |
1658 | ||
1659 | switch (Family) | |
afce4c03 VZ |
1660 | { |
1661 | case wxMODERN: | |
1662 | { | |
1663 | if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "CourBoO"; | |
1664 | else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "CourBo"; | |
1665 | else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "Cour0"; | |
1666 | else name = "Cour"; | |
1667 | } | |
1668 | break; | |
1669 | case wxROMAN: | |
1670 | { | |
1671 | if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "TimesBoO"; | |
1672 | else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "TimesBo"; | |
1673 | else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "TimesO"; | |
1674 | else if name = "TimesRo"; /* no typo */ | |
1675 | } | |
1676 | break; | |
1677 | default: | |
1678 | { | |
1679 | if ((Style == wxITALIC) && (Weight == wxBOLD)) name = "HelvBoO"; | |
1680 | else if ((Style != wxITALIC) && (Weight == wxBOLD)) name = "HelvBo"; | |
1681 | else if ((Style == wxITALIC) && (Weight != wxBOLD)) name = "Helv0"; | |
1682 | else name = "Helv"; | |
1683 | } | |
1684 | break; | |
1685 | } | |
36b3b54a RR |
1686 | |
1687 | /* get the directory of the AFM files */ | |
1688 | char afmName[256]; | |
1689 | afmName[0] = 0; | |
385bcb35 RR |
1690 | |
1691 | if (!m_printData.GetFontMetricPath().IsEmpty()) | |
1692 | { | |
1693 | strcpy( afmName, m_printData.GetFontMetricPath().mb_str() ) | |
1694 | } | |
36b3b54a | 1695 | |
afce4c03 VZ |
1696 | /* 2. open and process the file |
1697 | / a short explanation of the AFM format: | |
1698 | / we have for each character a line, which gives its size | |
1699 | / e.g.: | |
1700 | / | |
1701 | / C 63 ; WX 444 ; N question ; B 49 -14 395 676 ; | |
1702 | / | |
1703 | / that means, we have a character with ascii code 63, and width | |
1704 | / (444/1000 * fontSize) points. | |
1705 | / the other data is ignored for now! | |
1706 | / | |
1707 | / when the font has changed, we read in the right AFM file and store the | |
1708 | / character widths in an array, which is processed below (see point 3.). */ | |
36b3b54a RR |
1709 | |
1710 | /* new elements JC Sun Aug 25 23:21:44 MET DST 1996 */ | |
1711 | ||
1712 | strcat(afmName,name); | |
1713 | strcat(afmName,".afm"); | |
1714 | FILE *afmFile = fopen(afmName,"r"); | |
385bcb35 RR |
1715 | |
1716 | #ifdef __UNIX__ | |
1717 | if (afmFile==NULL) | |
1718 | { | |
1719 | strcpy( afmName, "/usr/local/share/wx/gs_afm/" ); | |
1720 | strcat(afmName,name); | |
1721 | strcat(afmName,".afm"); | |
1722 | FILE *afmFile = fopen(afmName,"r"); | |
1723 | } | |
1724 | ||
1725 | if (afmFile==NULL) | |
1726 | { | |
1727 | strcpy( afmName, "/usr/share/wx/gs_afm/" ); | |
1728 | strcat(afmName,name); | |
1729 | strcat(afmName,".afm"); | |
1730 | FILE *afmFile = fopen(afmName,"r"); | |
1731 | } | |
1732 | #endif | |
1733 | ||
1734 | if (afmFile==NULL) | |
36b3b54a RR |
1735 | { |
1736 | wxLogDebug( "GetTextExtent: can't open AFM file '%s'\n", afmName ); | |
1737 | wxLogDebug( " using approximate values\n"); | |
1738 | for (int i=0; i<256; i++) lastWidths[i] = 500; /* an approximate value */ | |
1739 | lastDescender = -150; /* dito. */ | |
ed880dd4 | 1740 | } |
afce4c03 VZ |
1741 | else |
1742 | { | |
36b3b54a RR |
1743 | /* init the widths array */ |
1744 | for(int i=0; i<256; i++) lastWidths[i] = INT_MIN; | |
1745 | /* some variables for holding parts of a line */ | |
1746 | char cString[10],semiString[10],WXString[10],descString[20]; | |
1747 | char upString[30], utString[30], encString[50]; | |
1748 | char line[256]; | |
1749 | int ascii,cWidth; | |
1750 | /* read in the file and parse it */ | |
1751 | while(fgets(line,sizeof(line),afmFile)!=NULL) | |
afce4c03 | 1752 | { |
36b3b54a RR |
1753 | /* A.) check for descender definition */ |
1754 | if (strncmp(line,"Descender",9)==0) | |
afce4c03 | 1755 | { |
36b3b54a | 1756 | if ((sscanf(line,"%s%d",descString,&lastDescender)!=2) || |
afce4c03 VZ |
1757 | (strcmp(descString,"Descender")!=0)) |
1758 | { | |
1759 | wxLogDebug( "AFM-file '%s': line '%s' has error (bad descender)\n", afmName,line ); | |
36b3b54a RR |
1760 | } |
1761 | } | |
1762 | /* JC 1.) check for UnderlinePosition */ | |
1763 | else if(strncmp(line,"UnderlinePosition",17)==0) | |
afce4c03 | 1764 | { |
36b3b54a | 1765 | if ((sscanf(line,"%s%lf",upString,&UnderlinePosition)!=2) || |
afce4c03 VZ |
1766 | (strcmp(upString,"UnderlinePosition")!=0)) |
1767 | { | |
1768 | wxLogDebug( "AFM-file '%s': line '%s' has error (bad UnderlinePosition)\n", afmName, line ); | |
36b3b54a RR |
1769 | } |
1770 | } | |
afce4c03 | 1771 | /* JC 2.) check for UnderlineThickness */ |
36b3b54a | 1772 | else if(strncmp(line,"UnderlineThickness",18)==0) |
afce4c03 | 1773 | { |
36b3b54a | 1774 | if ((sscanf(line,"%s%lf",utString,&UnderlineThickness)!=2) || |
afce4c03 VZ |
1775 | (strcmp(utString,"UnderlineThickness")!=0)) |
1776 | { | |
1777 | wxLogDebug( "AFM-file '%s': line '%s' has error (bad UnderlineThickness)\n", afmName, line ); | |
36b3b54a RR |
1778 | } |
1779 | } | |
afce4c03 | 1780 | /* JC 3.) check for EncodingScheme */ |
36b3b54a | 1781 | else if(strncmp(line,"EncodingScheme",14)==0) |
afce4c03 | 1782 | { |
36b3b54a | 1783 | if ((sscanf(line,"%s%s",utString,encString)!=2) || |
afce4c03 VZ |
1784 | (strcmp(utString,"EncodingScheme")!=0)) |
1785 | { | |
1786 | wxLogDebug("AFM-file '%s': line '%s' has error (bad EncodingScheme)\n", afmName, line ); | |
36b3b54a RR |
1787 | } |
1788 | else if (strncmp(encString, "AdobeStandardEncoding", 21)) | |
1789 | { | |
afce4c03 VZ |
1790 | wxLogDebug( "AFM-file '%s': line '%s' has error (unsupported EncodingScheme %s)\n", |
1791 | afmName,line, encString); | |
36b3b54a RR |
1792 | } |
1793 | } | |
1794 | /* B.) check for char-width */ | |
1795 | else if(strncmp(line,"C ",2)==0) | |
afce4c03 | 1796 | { |
36b3b54a | 1797 | if (sscanf(line,"%s%d%s%s%d",cString,&ascii,semiString,WXString,&cWidth)!=5) |
afce4c03 | 1798 | { |
36b3b54a RR |
1799 | wxLogDebug("AFM-file '%s': line '%s' has an error (bad character width)\n",afmName,line); |
1800 | } | |
1801 | if(strcmp(cString,"C")!=0 || strcmp(semiString,";")!=0 || strcmp(WXString,"WX")!=0) | |
afce4c03 | 1802 | { |
36b3b54a RR |
1803 | wxLogDebug("AFM-file '%s': line '%s' has a format error\n",afmName,line); |
1804 | } | |
1805 | /* printf(" char '%c'=%d has width '%d'\n",ascii,ascii,cWidth); */ | |
1806 | if (ascii>=0 && ascii<256) | |
afce4c03 | 1807 | { |
36b3b54a RR |
1808 | lastWidths[ascii] = cWidth; /* store width */ |
1809 | } | |
afce4c03 VZ |
1810 | else |
1811 | { | |
1812 | /* MATTHEW: this happens a lot; don't print an error */ | |
36b3b54a RR |
1813 | /* wxLogDebug("AFM-file '%s': ASCII value %d out of range\n",afmName,ascii); */ |
1814 | } | |
1815 | } | |
1816 | /* C.) ignore other entries. */ | |
1817 | } | |
1818 | fclose(afmFile); | |
ed880dd4 | 1819 | } |
36b3b54a | 1820 | /* hack to compute correct values for german 'Umlaute' |
afce4c03 VZ |
1821 | / the correct way would be to map the character names |
1822 | / like 'adieresis' to corresp. positions of ISOEnc and read | |
1823 | / these values from AFM files, too. Maybe later ... */ | |
36b3b54a RR |
1824 |