1 /********************************************************************************
2 *                                                                               *
3 *           D e v i c e   C o n t e x t   F o r   P r i n t i n g               *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or                 *
9 * modify it under the terms of the GNU Lesser General Public                    *
10 * License as published by the Free Software Foundation; either                  *
11 * version 2.1 of the License, or (at your option) any later version.            *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
16 * Lesser General Public License for more details.                               *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public              *
19 * License along with this library; if not, write to the Free Software           *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
21 *********************************************************************************
22 * $Id: FXDCPrint.cpp,v 1.54 2006/01/22 17:58:21 fox Exp $                       *
23 ********************************************************************************/
24 #include "xincs.h"
25 #include "fxver.h"
26 #include "fxdefs.h"
27 #include "fxkeys.h"
28 #include "FXHash.h"
29 #include "FXThread.h"
30 #include "FXStream.h"
31 #include "FXString.h"
32 #include "FXSize.h"
33 #include "FXPoint.h"
34 #include "FXRectangle.h"
35 #include "FXSettings.h"
36 #include "FXRegistry.h"
37 #include "FXAccelTable.h"
38 #include "FXApp.h"
39 #include "FXId.h"
40 #include "FXFont.h"
41 #include "FXCursor.h"
42 #include "FXDrawable.h"
43 #include "FXImage.h"
44 #include "FXBitmap.h"
45 #include "FXIcon.h"
46 #include "FXWindow.h"
47 #include "FXFrame.h"
48 #include "FXComposite.h"
49 #include "FXRootWindow.h"
50 #include "FXShell.h"
51 #include "FXRegion.h"
52 #include "FXDC.h"
53 #include "FXDCPrint.h"
54 
55 
56 /*
57   Notes:
58   - Contributed by celer@ipro.lug.usf.edu.
59   - Coordinate system starts in upper left corner, same as screen [which is
60     different from the way PostScript normally does things].
61   - Implement the many missing functions.
62   - Make it EPS compatible.
63   - Allow user to override PostScript Functions.
64   - Usage:
65     psdc.beginPrint(paper desc);
66     psdc.beginPage(pageno)
67     ....
68     drawing commands
69     ....
70     psdc.endPage();
71     psdc.endPrint();
72   - Perhaps feed into FXStream instead of FILE* this might be
73     cool to drag and drop [E]PS into apps...
74   - Do we still need the enum's in FXMediaSize if mediasize
75     indexes into the registry database's paper size list?
76 */
77 
78 using namespace FX;
79 
80 /*******************************************************************************/
81 
82 namespace FX {
83 
84 
85 // Construct
FXDCPrint(FXApp * a)86 FXDCPrint::FXDCPrint(FXApp* a):FXDC(a){
87   font=getApp()->getNormalFont();
88   psout=NULL;   // FIXME use ctx for this
89   mediawidth=0.0;
90   mediaheight=0.0;
91   mediabb.xmin=0.0;
92   mediabb.xmax=0.0;
93   mediabb.ymin=0.0;
94   mediabb.ymax=0.0;
95   docbb.xmin=0.0;
96   docbb.xmax=0.0;
97   docbb.ymin=0.0;
98   docbb.ymax=0.0;
99   pagebb.xmin=0.0;
100   pagebb.xmax=0.0;
101   pagebb.ymin=0.0;
102   pagebb.ymax=0.0;
103   pagecount=0;
104   nchars=0;
105   }
106 
107 
108 // Destruct
~FXDCPrint()109 FXDCPrint::~FXDCPrint(){
110   }
111 
112 
113 // Output hex number
outhex(FXuint hex)114 void FXDCPrint::outhex(FXuint hex){
115   if(!psout){ fxerror("FXDCPrint: no output device has been selected.\n"); }
116   fprintf((FILE*)psout,"%02x",hex);
117   if(++nchars>35){fputc('\n',(FILE*)psout);nchars=0;}
118   }
119 
120 
121 // Output formatted stuff
outf(const char * format,...)122 void FXDCPrint::outf(const char* format,...){
123   va_list arguments;
124   if(!psout){ fxerror("FXDCPrint: no output device has been selected.\n"); }
125   va_start(arguments,format);
126   vfprintf((FILE*)psout,format,arguments);
127   va_end(arguments);
128   }
129 
130 
131 // Extends bounding box with point x,y
bbox(FXfloat x,FXfloat y)132 void FXDCPrint::bbox(FXfloat x,FXfloat y){
133   if(x<pagebb.xmin) pagebb.xmin=x;
134   if(pagebb.xmax<x) pagebb.xmax=x;
135   if(y<pagebb.ymin) pagebb.ymin=y;
136   if(pagebb.ymax<y) pagebb.ymax=y;
137   }
138 
139 
140 // Send the range of coordinates that will be sent
setContentRange(FXint pxminArg,FXint pyminArg,FXint pxmaxArg,FXint pymaxArg)141 FXbool FXDCPrint::setContentRange(FXint pxminArg, FXint pyminArg, FXint pxmaxArg, FXint pymaxArg){
142   if(flags&PRINT_LANDSCAPE){
143     pxmin=pyminArg;
144     pymin=pxminArg;
145     pxmax=pymaxArg;
146     pymax=pxmaxArg;
147     }
148   else{
149     pxmin=pxminArg;
150     pymin=pyminArg;
151     pxmax=pxmaxArg;
152     pymax=pymaxArg;
153     }
154   return TRUE;    // Should we check for appropriate ranges?
155   }
156 
157 
158 // Transform point
tfm(FXfloat & xo,FXfloat & yo,FXfloat xi,FXfloat yi)159 void FXDCPrint::tfm(FXfloat& xo,FXfloat& yo,FXfloat xi,FXfloat yi){
160 /*
161   if(flags&PRINT_LANDSCAPE){
162     xo=yi;
163     yo=(FXfloat)(mediaheight-xi);
164     }
165   else{
166     xo=xi;
167     yo=(FXfloat)(mediaheight-yi);
168     }
169 */
170   FXfloat pxrange=static_cast<FXfloat>(pxmax-pxmin);
171   FXfloat pyrange=static_cast<FXfloat>(pymax-pymin);
172   FXfloat mxmin,mxmax,mymin,mymax,mxrange,myrange;
173 
174   if(flags&PRINT_LANDSCAPE){
175     mxmin=static_cast<FXfloat>(mediabb.ymin);
176     mxmax=static_cast<FXfloat>(mediabb.ymax);
177     //mymin=static_cast<FXfloat>(mediawidth-mediabb.xmax);
178     //mymax=static_cast<FXfloat>(mediawidth-mediabb.xmin);
179     mymin=static_cast<FXfloat>(mediabb.xmin);
180     mymax=static_cast<FXfloat>(mediabb.xmax);
181     mxrange=mxmax-mxmin;
182     myrange=mymax-mymin;
183     //xo=xi;
184     //yo=mediawidth-yi;
185     }
186   else{
187     mxmin=static_cast<FXfloat>(mediabb.xmin);
188     mxmax=static_cast<FXfloat>(mediabb.xmax);
189     mymin=static_cast<FXfloat>(mediabb.ymin);
190     mymax=static_cast<FXfloat>(mediabb.ymax);
191     mxrange=mxmax-mxmin;
192     myrange=mymax-mymin;
193     }
194 
195   if (pyrange/pxrange<=myrange/mxrange) { // short/wide
196     xo=mxmin+((xi-pxmin)/pxrange)*mxrange;
197     yo=mymin+.5f*(myrange-pyrange*(mxrange/pxrange))+(pyrange-yi)*(mxrange/pxrange);
198     }
199   else {// tall/thin
200     xo=mxmin+.5f*(mxrange-pxrange*(myrange/pyrange))+xi*(myrange/pyrange);
201     yo=mymin+((pyrange-yi)/pyrange)*myrange;
202     }
203   }
204 
205 
206 // Generate print job prolog
beginPrint(FXPrinter & job)207 FXbool FXDCPrint::beginPrint(FXPrinter& job){
208   int numpages;
209 
210   Yr=792;  //480 // This is essentially the height of the page(used so that the upper left hand corner is the origin)
211   Xr=0;
212 
213   // Print to file
214   if(job.flags&PRINT_DEST_FILE){
215     psout=fopen(job.name.text(),"w");
216     if(!psout) return FALSE;
217     }
218 
219   // Print to printer
220   else{
221     char buffer[1000];
222     const FXchar* printercmd=getApp()->reg().readStringEntry("PRINTER","command","lpr -P%s -#%d");
223     sprintf(buffer,printercmd,job.name.text(),job.numcopies);
224 #ifdef WIN32
225 #ifndef _WINDOWS
226 #ifdef __CYGWIN__
227     psout=popen(buffer,"w");
228 #else
229     psout=_popen(buffer,"w"); // _popen() available for console apps only!
230 #endif
231 #else
232     psout=0;
233 #endif
234 #else
235     psout=popen(buffer,"w");
236 #endif
237     if(!psout) return FALSE;
238     }
239 
240   // Copy flags
241   flags=job.flags;
242 
243   // This determines transformations
244   mediawidth=(FXfloat)job.mediawidth;
245   mediaheight=(FXfloat)job.mediaheight;
246 
247   // Set media bb; this determines transformation
248   mediabb.xmin=(FXfloat)job.leftmargin;
249   mediabb.xmax=(FXfloat)(job.mediawidth-job.rightmargin);
250   mediabb.ymin=(FXfloat)job.bottommargin;
251   mediabb.ymax=(FXfloat)(job.mediaheight-job.topmargin);
252 
253   // Initialize page and document bb from media bb
254   pagebb=mediabb;
255   docbb=mediabb;
256 
257   // Begin header
258   outf("%%!PS-Adobe-3.0\n");
259   outf("%%%%Title: Print Job\n");
260   outf("%%%%Creator: FOX GUI Toolkit Application\n");
261 
262   // Bounding box
263   if(flags&PRINT_NOBOUNDS){
264     docbb.xmin= 1000000.0;
265     docbb.xmax=-1000000.0;
266     docbb.ymin= 1000000.0;
267     docbb.ymax=-1000000.0;
268     outf("%%%%BoundingBox: (atend)\n");
269     }
270   else{
271     docbb.xmin=(FXfloat)job.leftmargin;
272     docbb.xmax=(FXfloat)(job.mediawidth-job.rightmargin);
273     docbb.ymin=(FXfloat)job.bottommargin;
274     docbb.ymax=(FXfloat)(job.mediaheight-job.topmargin);
275     outf("%%%%BoundingBox: %d %d %d %d\n",(int)docbb.xmin,(int)docbb.ymin,(int)docbb.xmax,(int)docbb.ymax);
276     }
277   setContentRange((int)docbb.xmin, (int)docbb.ymin, (int)docbb.xmax, (int)docbb.ymax);
278 
279   // Calculate number of pages
280   numpages=0;
281   if(flags&PRINT_PAGES_ODD){
282     numpages=1+(job.topage-job.frompage)/2;
283     }
284   else if(flags&PRINT_PAGES_EVEN){
285     numpages=1+(job.topage-job.frompage)/2;
286     }
287   else if(flags&PRINT_PAGES_RANGE){
288     numpages=1+job.topage-job.frompage;
289     }
290 
291   // How many pages are coming
292   if(numpages==0){
293     outf("%%%%Pages: (atend)\n");
294     }
295   else{
296     outf("%%%%Pages: %d\n",numpages);
297     }
298 
299   outf("%%%%DocumentFonts:\n");
300   outf("%%%%EndComments\n");
301 
302   // Procedure definitions
303   outf("%%%%BeginProlog\n\n\n");
304 
305   // Various definitions
306   outf("%% h w x y drawRect\n");
307   outf("/drawRect {\n\tnewpath moveto dup 0 rlineto exch dup 0 exch\n\trlineto exch neg 0 rlineto neg 0 exch rlineto\n\tclosepath stroke\n} def\n");
308   outf("%% h w x y fillRect\n");
309   outf("/fillRect {\n\tnewpath moveto dup 0 rlineto exch dup 0 exch\n\trlineto exch neg 0 rlineto neg 0 exch rlineto\n\tclosepath fill stroke\n} def\n");
310   outf("%% x y a b drawLine\n");
311   outf("/drawLine {\n\tnewpath moveto lineto stroke\n} def\n");
312   outf("%% x y ..... npoints drawLines\n");
313   outf("/drawLines {\n\t3 1 roll newpath moveto {lineto} repeat stroke\n} def\n");
314   outf("%% x y a b ..... nsegments drawSegmt\n");
315   outf("/drawSegmt {\n\tnewpath {\n\t\tmoveto lineto\n\t} repeat stroke\n} def\n");
316   outf("%% x y drawPoint\n");
317   outf("/drawPoint {\n\ttranslate 1 1 scale 8 8 1 [ 8 0 0 8 0 0 ] {<0000>} image\n} def\n");
318   outf("%% centerx centery  startAngle endAngle radiusX radiusY drawArc\n");
319   outf("/drawArc {\n\tgsave dup 3 1 roll div dup 1 scale 6 -1 roll\n\texch div 5 1 roll  3 -2 roll arc stroke grestore\n} def\n");
320   outf("%% (string) x y height drawText\n");
321   outf("/drawText {\n\tgsave findfont exch scalefont setfont moveto\n\tshow grestore\n} def\n");
322 
323   // Image operator
324   outf("/bwproc\n");
325   outf(" {  rgbproc\n");
326   outf("    dup length 3 idiv string 0 3 0\n");
327   outf("    5 -1 roll\n");
328   outf("    { add 2 1 roll 1 sub dup 0 eq\n");
329   outf("      { pop 3 idiv 3 -1 roll dup 4 -1 roll dup\n");
330   outf("        3 1 roll 5 -1 roll put 1 add 3 0 }\n");
331   outf("      { 2 1 roll } ifelse\n");
332   outf("    } forall\n");
333   outf("    pop pop pop\n");
334   outf("} def\n");
335   outf("systemdict /colorimage known not\n");
336   outf(" { /colorimage\n");
337   outf("     { pop pop /rgbproc exch def\n");
338   outf("     { bwproc } image\n");
339   outf(" } def\n");
340   outf("} if\n");
341 
342   // For 3D
343   outf("%% Color -  r g b C\n");
344   outf("/C { setrgbcolor } bind def\n");
345 
346   outf("%% Point -  x y r g b P\n");
347   outf("/P { C newpath 0.5 0.0 360.0 arc closepath fill } bind def\n");
348 
349   outf("%% Flat Shaded Line -  x2 y2 x1 y1 r g b L\n");
350   outf("/L { C newpath moveto lineto stroke } bind def\n");
351 
352   outf("%% Smooth-shaded line -  x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 SL\n");
353   outf("/SL {\n");
354   outf(" /b1 exch def\n");
355   outf(" /g1 exch def\n");
356   outf(" /r1 exch def\n");
357   outf(" /y1 exch def\n");
358   outf(" /x1 exch def\n");
359   outf(" /b2 exch def\n");
360   outf(" /g2 exch def\n");
361   outf(" /r2 exch def\n");
362   outf(" /y2 exch def\n");
363   outf(" /x2 exch def\n");
364   outf("\n");
365   outf(" b2 b1 sub abs 0.01 gt\n");
366   outf(" g2 g1 sub abs 0.005 gt\n");
367   outf(" r2 r1 sub abs 0.008 gt\n");
368   outf("     or or {\n");
369   outf("         /bm b1 b2 add 0.5 mul def\n");
370   outf("         /gm g1 g2 add 0.5 mul def\n");
371   outf("         /rm r1 r2 add 0.5 mul def\n");
372   outf("         /ym y1 y2 add 0.5 mul def\n");
373   outf("         /xm x1 x2 add 0.5 mul def\n");
374   outf("\n");
375   outf("         x1 y1 r1 g1 b1 xm ym rm gm bm SL\n");
376   outf("         xm ym rm gm bm x2 y2 r2 g2 b2 SL\n");
377   outf(" } {\n");
378   outf("         x1 y1 x2 y2 r1 g1 b1 L\n");
379   outf(" } ifelse\n");
380   outf("} bind def\n");
381 
382   outf("%% Flat-shaded triangle - x3 y3 x2 y2 x1 y1 r g b T\n");
383   outf("/T { C newpath moveto lineto lineto closepath fill } bind def\n");
384 
385   outf("%% Smooth-shaded triangle - x3 y3 r3 g3 b3 x2 y2 r2 g2 b2 x1 y1 r1 g1 b1 ST\n");
386   outf("/ST {\n");
387   outf(" /b1 exch def\n");
388   outf(" /g1 exch def\n");
389   outf(" /r1 exch def\n");
390   outf(" /y1 exch def\n");
391   outf(" /x1 exch def\n");
392   outf(" /b2 exch def\n");
393   outf(" /g2 exch def\n");
394   outf(" /r2 exch def\n");
395   outf(" /y2 exch def\n");
396   outf(" /x2 exch def\n");
397   outf(" /b3 exch def\n");
398   outf(" /g3 exch def\n");
399   outf(" /r3 exch def\n");
400   outf(" /y3 exch def\n");
401   outf(" /x3 exch def\n");
402   outf("\n");
403   outf(" b2 b1 sub abs 0.05 gt\n");
404   outf(" g2 g1 sub abs 0.017 gt\n");
405   outf(" r2 r1 sub abs 0.032 gt\n");
406   outf(" b3 b1 sub abs 0.05 gt\n");
407   outf(" g3 g1 sub abs 0.017 gt\n");
408   outf(" r3 r1 sub abs 0.032 gt\n");
409   outf(" b2 b3 sub abs 0.05 gt\n");
410   outf(" g2 g3 sub abs 0.017 gt\n");
411   outf(" r2 r3 sub abs 0.032 gt\n");
412   outf(" or or or or or or or or {\n");
413   outf("         /b12 b1 b2 add 0.5 mul def\n");
414   outf("         /g12 g1 g2 add 0.5 mul def\n");
415   outf("         /r12 r1 r2 add 0.5 mul def\n");
416   outf("         /y12 y1 y2 add 0.5 mul def\n");
417   outf("         /x12 x1 x2 add 0.5 mul def\n");
418   outf("\n");
419   outf("         /b13 b1 b3 add 0.5 mul def\n");
420   outf("         /g13 g1 g3 add 0.5 mul def\n");
421   outf("         /r13 r1 r3 add 0.5 mul def\n");
422   outf("         /y13 y1 y3 add 0.5 mul def\n");
423   outf("         /x13 x1 x3 add 0.5 mul def\n");
424   outf("\n");
425   outf("         /b32 b3 b2 add 0.5 mul def\n");
426   outf("         /g32 g3 g2 add 0.5 mul def\n");
427   outf("         /r32 r3 r2 add 0.5 mul def\n");
428   outf("         /y32 y3 y2 add 0.5 mul def\n");
429   outf("         /x32 x3 x2 add 0.5 mul def\n");
430   outf("\n");
431   outf("         x1 y1 r1 g1 b1 x12 y12 r12 g12 b12 x13 y13 r13 g13 b13\n");
432   outf("         x2 y2 r2 g2 b2 x12 y12 r12 g12 b12 x32 y32 r32 g32 b32\n");
433   outf("         x3 y3 r3 g3 b3 x32 y32 r32 g32 b32 x13 y13 r13 g13 b13\n");
434   outf("         x32 y32 r32 g32 b32 x12 y12 r12 g12 b12 x13 y13 r13 g13 b13\n");
435   outf("         ST ST ST ST\n");
436   outf(" } {\n");
437   outf("         x1 y1 x2 y2 x3 y3 r1 g1 b1 T\n");
438   outf(" } ifelse\n");
439   outf("} bind def\n");
440 
441   // End of prologue
442   outf("%%%%EndProlog\n");
443 
444 
445   // Document setup
446   outf("%%%%BeginSetup\n");
447   outf("/#copies %d def\n",job.numcopies);
448   outf("%%%%EndSetup\n");
449 
450   // Keep track of #pages
451   pagecount=0;
452 
453   return TRUE;
454   }
455 
456 
457 // Generate print job epilog
endPrint()458 FXbool FXDCPrint::endPrint(){
459   outf("%%%%Trailer\n");
460 
461   // We now know the bounding box
462   if(flags&PRINT_NOBOUNDS){
463     if(docbb.xmin<docbb.xmax && docbb.ymin<docbb.ymax){
464       outf("%%%%BoundingBox: %d %d %d %d\n",(int)docbb.xmin,(int)docbb.ymin,(int)docbb.xmax,(int)docbb.ymax);
465       }
466     else{
467       outf("%%%%BoundingBox: 0 0 100 100\n");   // Gotta come up with something...
468       }
469     }
470 
471   // We now know the page count
472   if(!(flags&(PRINT_PAGES_ODD|PRINT_PAGES_EVEN|PRINT_PAGES_RANGE))){
473     outf("%%%%Pages: %d\n",pagecount);
474     }
475 
476   // Done!
477   outf("%%%%EOF\n");
478   fclose((FILE*)psout);
479   return TRUE;
480   }
481 
482 
483 // Generate begin of page
beginPage(FXuint page)484 FXbool FXDCPrint::beginPage(FXuint page){
485 
486   // Output page number
487   outf("%%%%Page: %d\n",page);
488 
489   // Reset page bounding box
490   if(flags&PRINT_NOBOUNDS){
491     pagebb.xmin= 1000000;
492     pagebb.xmax=-1000000;
493     pagebb.ymin= 1000000;
494     pagebb.ymax=-1000000;
495     outf("%%%%PageBoundingBox: (atend)\n");
496     }
497 
498   // Use the doc bounding box
499   else{
500     pagebb.xmin=docbb.xmin;
501     pagebb.xmax=docbb.xmax;
502     pagebb.ymin=docbb.ymin;
503     pagebb.ymax=docbb.ymax;
504     outf("%%%%PageBoundingBox: %d %d %d %d\n",(int)pagebb.xmin,(int)pagebb.ymin,(int)pagebb.xmax,(int)pagebb.ymax);
505     }
506 
507   // Page setup
508   outf("%%%%BeginPageSetup\n");
509   outf("%%%%EndPageSetup\n");
510   outf("gsave\n");
511 
512   // Maybe in landscape?
513   if(flags&PRINT_LANDSCAPE){
514     outf("%g %g translate\n",mediawidth,0.0);
515     outf("90 rotate\n");
516     }
517 
518   return TRUE;
519   }
520 
521 
522 // Generate end of page
endPage()523 FXbool FXDCPrint::endPage(){
524   /*
525   outf("0 0 0 setcolor\n");
526   outf("newpath\n");
527   outf("%g %g moveto\n",mediabb.xmin,mediabb.ymin);
528   outf("%g %g lineto\n",mediabb.xmin,mediabb.ymax);
529   outf("%g %g lineto\n",mediabb.xmax,mediabb.ymax);
530   outf("%g %g lineto\n",mediabb.xmax,mediabb.ymin);
531   outf("%g %g lineto\n",mediabb.xmin,mediabb.ymin);
532   outf("stroke\n");
533   outf("newpath\n");
534   outf("%g %g moveto\n",mediabb.xmin,mediabb.ymin);
535   outf("%g %g lineto\n",mediabb.xmax,mediabb.ymax);
536   outf("stroke\n");
537   outf("newpath\n");
538   outf("%g %g moveto\n",mediabb.xmin,mediabb.ymax);
539   outf("%g %g lineto\n",mediabb.xmax,mediabb.ymin);
540   outf("stroke\n");
541   */
542   outf("%%%%PageTrailer\n");
543 
544   // We now know the bounding box
545   if(flags&PRINT_NOBOUNDS){
546     if(pagebb.xmin<pagebb.xmax && pagebb.ymin<pagebb.ymax){
547       outf("%%%%BoundingBox: %d %d %d %d\n",(int)pagebb.xmin,(int)pagebb.ymin,(int)pagebb.xmax,(int)pagebb.ymax);
548       }
549     else{
550       outf("%%%%BoundingBox: 0 0 100 100\n");   // Gotta come up with something...
551       }
552     }
553   outf("showpage\n");
554   outf("grestore\n");
555   pagecount++;
556   return TRUE;
557   }
558 
559 
560 // Draw a point in the current pen color
drawPoint(FXint x,FXint y)561 void FXDCPrint::drawPoint(FXint x,FXint y){
562   FXfloat xx,yy;
563   tfm(xx,yy,(FXfloat)x,(FXfloat)y);
564   bbox(xx,yy);
565   outf("%g %g 0.5 0 360 arc fill\n",xx,yy);
566   }
567 
568 
569 // Draw points in the current pen color.
570 // Each point's position is relative to the drawable's origin (as usual).
drawPoints(const FXPoint * points,FXuint npoints)571 void FXDCPrint::drawPoints(const FXPoint* points,FXuint npoints){
572   register FXuint i;
573   FXfloat xx,yy;
574   for(i=0; i<npoints; i++){
575     tfm(xx,yy,points[i].x,points[i].y);
576     bbox(xx,yy);
577     outf("%g %g 0.5 0 360 arc fill\n",xx,yy);
578     }
579   }
580 
581 
582 // Draw points in the current pen color. The first point's position is
583 // relative to the drawable's origin, but each subsequent point's position
584 // is relative to the previous point's position; each FXPoint defines
585 // the relative coordinates. Think LOGO.
drawPointsRel(const FXPoint *,FXuint)586 void FXDCPrint::drawPointsRel(const FXPoint*,FXuint){
587   }
588 
589 
590 // Draw a line
drawLine(FXint x1,FXint y1,FXint x2,FXint y2)591 void FXDCPrint::drawLine(FXint x1,FXint y1,FXint x2,FXint y2){
592   FXfloat xx1,yy1,xx2,yy2;
593   tfm(xx1,yy1,(FXfloat)x1,(FXfloat)y1);
594   tfm(xx2,yy2,(FXfloat)x2,(FXfloat)y2);
595   bbox(xx1,yy1);
596   bbox(xx2,yy2);
597   outf("newpath %g %g moveto %g %g lineto stroke\n",xx1,yy1,xx2,yy2);
598   }
599 
600 
601 // Draw multiple lines. All points are drawn connected.
602 // Each point is specified relative to Drawable's origin.
drawLines(const FXPoint * points,FXuint npoints)603 void FXDCPrint::drawLines(const FXPoint* points,FXuint npoints){
604   register FXuint i;
605   FXfloat xx,yy;
606   if(npoints<2) return;
607   tfm(xx,yy,points[0].x,points[0].y);
608   bbox(xx,yy);
609   outf("newpath %g %g moveto",xx,yy);
610   for(i=1; i<npoints; i++){
611     tfm(xx,yy,points[i].x,points[i].y);
612     bbox(xx,yy);
613     outf(" %g %g lineto",xx,yy);
614     }
615   outf(" stroke\n");
616   }
617 
618 
619 // Draw multiple lines. All points are drawn connected.
620 // First point's coordinate is relative to drawable's origin, but
621 // subsequent points' coordinates are relative to previous point.
drawLinesRel(const FXPoint * points,FXuint npoints)622 void FXDCPrint::drawLinesRel(const FXPoint* points,FXuint npoints){
623   register FXuint i,x,y;
624   FXfloat xx,yy;
625   if(npoints<2) return;
626   x=points[0].x;
627   y=points[0].y;
628   tfm(xx,yy,(FXfloat)x,(FXfloat)y);
629   bbox(xx,yy);
630   outf("newpath %g %g moveto",xx,yy);
631   for(i=1; i<npoints; i++){
632     x+=points[i].x;
633     y+=points[i].y;
634     tfm(xx,yy,(FXfloat)x,(FXfloat)y);
635     bbox(xx,yy);
636     outf(" %g %g lineto",xx,yy);
637     }
638   outf(" stroke\n");
639   }
640 
641 
642 // Draw unconnected line segments
drawLineSegments(const FXSegment * segments,FXuint nsegments)643 void FXDCPrint::drawLineSegments(const FXSegment* segments,FXuint nsegments){
644   register FXuint i;
645   for(i=0; i<=nsegments; i++)
646     outf(" %d %d %d %d",
647 		segments[i].x1,Yr-segments[i].y1,
648 		segments[i].x2,Yr-segments[i].y2);
649   outf(" %d drawSegmt\n",nsegments);
650   }
651 
652 
653 // Draw unfilled rectangle
drawRectangle(FXint x,FXint y,FXint w,FXint h)654 void FXDCPrint::drawRectangle(FXint x,FXint y,FXint w,FXint h){
655   FXfloat xl,xr,yt,yb;
656   tfm(xl,yt,(FXfloat)x,(FXfloat)y);
657   tfm(xr,yb,(FXfloat)(x+w-1),(FXfloat)(y+h-1));
658   bbox(xl,yt);
659   bbox(xr,yb);
660   outf("newpath %g %g moveto %g %g lineto %g %g lineto %g %g lineto %g %g lineto stroke\n",xl,yt,xr,yt,xr,yb,xl,yb,xl,yt);
661   }
662 
663 
664 // Draw unfilled rectangles
drawRectangles(const FXRectangle * rectangles,FXuint nrectangles)665 void FXDCPrint::drawRectangles(const FXRectangle* rectangles,FXuint nrectangles){
666   register FXuint i;
667   for(i=0; i<nrectangles; i++){
668     drawRectangle(rectangles[i].x,rectangles[i].y,rectangles[i].w,rectangles[i].h);
669     }
670   }
671 
672 
673 // Unfilled rounded rectangle
drawRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint)674 void FXDCPrint::drawRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint){
675   }
676 
677 
678 // Draw arc (patch from: sancelot@crosswinds.net)
drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2)679 void FXDCPrint::drawArc(FXint x,FXint y,FXint w,FXint h,FXint ang1,FXint ang2){
680   FXfloat startAngle,endAngle,xx,yy,yr;
681   startAngle=((float)ang1)/64.0f;
682   endAngle=startAngle+(((float) ang2)/64.0f);
683   tfm(xx,yy,(FXfloat)x,(FXfloat)y);
684   tfm(xx,yr,(FXfloat)x,(FXfloat)Yr);
685   outf("%1.3f %1.3f %1.3f %1.3f %1.3f %1.3f drawArc\n",xx+(w/2.0),yy-(h/2.0),startAngle,endAngle,w/2.0,h/2.0);
686   }
687 
688 
689 
690 // Draw arcs
drawArcs(const FXArc *,FXuint)691 void FXDCPrint::drawArcs(const FXArc*,FXuint){
692   }
693 
694 
695 // Draw ellipse
drawEllipse(FXint,FXint,FXint,FXint)696 void FXDCPrint::drawEllipse(FXint,FXint,FXint,FXint){
697   }
698 
699 
700 // Filled rectangle
fillRectangle(FXint x,FXint y,FXint w,FXint h)701 void FXDCPrint::fillRectangle(FXint x,FXint y,FXint w,FXint h){
702   FXfloat xl,xr,yt,yb;
703   tfm(xl,yt,(FXfloat)x,(FXfloat)y);
704   tfm(xr,yb,(FXfloat)(x+w-1),(FXfloat)(y+h-1));
705   bbox(xl,yt);
706   bbox(xr,yb);
707   outf("newpath %g %g moveto %g %g lineto %g %g lineto %g %g lineto %g %g lineto fill\n",xl,yt,xr,yt,xr,yb,xl,yb,xl,yt);
708   }
709 
710 
711 // Filled rectangles
fillRectangles(const FXRectangle * rectangles,FXuint nrectangles)712 void FXDCPrint::fillRectangles(const FXRectangle* rectangles,FXuint nrectangles){
713   register FXuint i;
714   for(i=0; i<nrectangles; i++){
715     fillRectangle(rectangles[i].x,rectangles[i].y,rectangles[i].w,rectangles[i].h);
716     }
717   }
718 
719 
720 // Fill using currently selected ROP mode
fillRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint)721 void FXDCPrint::fillRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint){
722   }
723 
724 
725 // Fill chord
fillChord(FXint,FXint,FXint,FXint,FXint,FXint)726 void FXDCPrint::fillChord(FXint,FXint,FXint,FXint,FXint,FXint){
727   }
728 
729 
730 // Fill chords
fillChords(const FXArc *,FXuint)731 void FXDCPrint::fillChords(const FXArc*,FXuint){
732   }
733 
734 
735 
736 // Fill arc
fillArc(FXint,FXint,FXint,FXint,FXint,FXint)737 void FXDCPrint::fillArc(FXint,FXint,FXint,FXint,FXint,FXint){
738   }
739 
740 
741 // Fill arcs
fillArcs(const FXArc *,FXuint)742 void FXDCPrint::fillArcs(const FXArc*,FXuint){
743   }
744 
745 
746 // Fill ellipse
fillEllipse(FXint,FXint,FXint,FXint)747 void FXDCPrint::fillEllipse(FXint,FXint,FXint,FXint){
748   }
749 
750 
751 // Filled simple polygon
fillPolygon(const FXPoint * points,FXuint npoints)752 void FXDCPrint::fillPolygon(const FXPoint* points,FXuint npoints){
753   register FXuint i;
754   FXfloat xx,yy;
755   if(npoints<2) return;
756   tfm(xx,yy,points[0].x,points[0].y);
757   bbox(xx,yy);
758   outf("newpath %g %g moveto",xx,yy);
759   for(i=1; i<npoints; i++){
760     tfm(xx,yy,points[i].x,points[i].y);
761     bbox(xx,yy);
762     outf(" %g %g lineto",xx,yy);
763     }
764   outf(" fill\n");
765   }
766 
767 
768 // Fill concave polygon
fillConcavePolygon(const FXPoint *,FXuint)769 void FXDCPrint::fillConcavePolygon(const FXPoint*,FXuint){
770   }
771 
772 
773 // Fill complex (self-intersecting) polygon
fillComplexPolygon(const FXPoint *,FXuint)774 void FXDCPrint::fillComplexPolygon(const FXPoint*,FXuint){
775   }
776 
777 
778 // Filled simple polygon with relative points
fillPolygonRel(const FXPoint *,FXuint)779 void FXDCPrint::fillPolygonRel(const FXPoint*,FXuint){
780   }
781 
782 
783 // Fill concave polygon
fillConcavePolygonRel(const FXPoint *,FXuint)784 void FXDCPrint::fillConcavePolygonRel(const FXPoint*,FXuint){
785   }
786 
787 
788 // Fill complex (self-intersecting) polygon
fillComplexPolygonRel(const FXPoint *,FXuint)789 void FXDCPrint::fillComplexPolygonRel(const FXPoint*,FXuint){
790   }
791 
792 
793 // Draw string with base line starting at x, y
drawText(FXint x,FXint y,const FXchar * string,FXuint len)794 void FXDCPrint::drawText(FXint x,FXint y,const FXchar* string,FXuint len){
795 /*
796   FXfloat xx,yy;
797   tfm(xx,yy,(FXfloat)x,(FXfloat)y);
798   bbox(xx,yy);
799   FXFontDesc fontdesc;
800   font->getFontDesc(fontdesc);
801   outf("gsave /%s findfont\n",font->getName().text());
802   outf("%d scalefont\n",font->getSize()/10);
803   outf("setfont\n");
804   outf("newpath\n%g %g moveto\n(",xx,yy);
805   for(FXuint i=0; i<len; i++){
806     if(string[i]=='(') outf("\\050");
807     else if(string[i]==')') outf("\\051");
808     else outf("%c",string[i]);
809     }
810   outf(") show\n");
811   outf("grestore\n");
812 */
813   FXfloat xx,yy;
814   tfm(xx,yy,(FXfloat)x,(FXfloat)y);
815 
816   // old font size was hardcoded...
817   //outf("(%s) %g %g %d /Courier drawText\n",string,xx,yy,15);
818 
819   //FXfloat pxrange=static_cast<FXfloat>(pxmax-pxmin);
820   //FXfloat pyrange=static_cast<FXfloat>(pymax-pymin);
821   //FXfloat mxmin,mxmax,mymin,mymax,mxrange,myrange;
822 
823 /*  if(flags&PRINT_LANDSCAPE){
824     mxmin=static_cast<FXfloat>(mediabb.ymin);
825     mxmax=static_cast<FXfloat>(mediabb.ymax);
826     //mymin=static_cast<FXfloat>(mediawidth-mediabb.xmax);
827     //mymax=static_cast<FXfloat>(mediawidth-mediabb.xmin);
828     mymin=static_cast<FXfloat>(mediabb.xmin);
829     mymax=static_cast<FXfloat>(mediabb.xmax);
830     mxrange=mxmax-mxmin;
831     myrange=mymax-mymin;
832     }
833   else{
834     mxmin=static_cast<FXfloat>(mediabb.xmin);
835     mxmax=static_cast<FXfloat>(mediabb.xmax);
836     mymin=static_cast<FXfloat>(mediabb.ymin);
837     mymax=static_cast<FXfloat>(mediabb.ymax);
838     mxrange=mxmax-mxmin;
839     myrange=mymax-mymin;
840     }
841 */
842   FXfloat fsize=0.1f*font->getSize();
843   // Hack...
844   // Account for dpi and scale up or down with graph...
845   // Perhaps override screen resolution via registry
846   //  FXint screenres=getApp()->reg().readUnsignedEntry("SETTINGS","screenres",100);
847 
848   // Validate
849 /*  if(screenres<50) screenres=50;
850   if(screenres>200) screenres=200;
851 
852   if(pyrange/pxrange<=myrange/mxrange){ // short/wide
853     fsize *= (mxrange/pxrange)*(screenres/72.f);
854     }
855   else{// tall/thin
856     fsize *= (myrange/pyrange)*(screenres/72.f);
857     }
858 */
859 
860   FXString fname=font->getName();
861   if(fname=="times"){
862     fname="Times";
863     }
864   else if(fname=="helvetica"){
865     fname="Helvetica";
866     }
867   else if(fname=="courier"){
868     fname="Courier";
869     }
870   else{
871     fname="Courier";
872     }
873   if(font->getWeight()==FXFont::Bold){
874     if(font->getSlant()==FXFont::Italic){
875       fname+="-BoldItalic";
876       }
877     else if(font->getSlant()==FXFont::Oblique){
878       fname+="-BoldOblique";
879       }
880     else {
881       fname+="-Bold";
882       }
883     }
884   else{
885     if(font->getSlant()==FXFont::Italic){
886       fname+="-Italic";
887       }
888     else if(font->getSlant()==FXFont::Oblique){
889       fname+="-Oblique";
890       }
891     }
892   if(fname=="Times"){
893     fname+="-Roman";
894     }
895 
896   outf("(%s) %g %g %d /%s drawText\n",string,xx,yy,(int)fsize,fname.text());
897   }
898 
899 
900 // Draw string with base line starting at x, y
drawText(FXint x,FXint y,const FXString & string)901 void FXDCPrint::drawText(FXint x,FXint y,const FXString& string){
902   drawText(x,y,string.text(),string.length());
903   }
904 
905 
906 // Draw string with base line starting at x, y over filled background
drawImageText(FXint,FXint,const FXchar *,FXuint)907 void FXDCPrint::drawImageText(FXint,FXint,const FXchar*,FXuint){
908   }
909 
910 
911 // Draw string with base line starting at x, y over filled background
drawImageText(FXint x,FXint y,const FXString & string)912 void FXDCPrint::drawImageText(FXint x,FXint y,const FXString& string){
913   drawImageText(x,y,string.text(),string.length());
914   }
915 
916 
917 // Draw area from source
drawArea(const FXDrawable *,FXint,FXint,FXint,FXint,FXint,FXint)918 void FXDCPrint::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint){
919   }
920 
921 
922 // Draw area stretched area from source
drawArea(const FXDrawable *,FXint,FXint,FXint,FXint,FXint,FXint,FXint,FXint)923 void FXDCPrint::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint,FXint,FXint){
924   }
925 
926 
927 // Draw image
928 // Contibuted by dwalz@cs.uni-magdeburg.de
drawImage(const FXImage * img,FXint dx,FXint dy)929 void FXDCPrint::drawImage(const FXImage *img,FXint dx,FXint dy){
930   FXuint opts=img->getOptions();
931   if(opts&IMAGE_OWNED){
932     FXint    ww  = img->getWidth();
933     FXint    hh = img->getHeight();
934     FXuchar *buffer = (FXuchar*)img->getData();
935 
936     outf("/picstr %d string def\n",ww*3);
937     outf("%d %d translate\n",dx,hh-dy);
938     outf("%d %d scale\n",ww,-hh);
939     outf("%d %d %d\n",ww,hh,8);
940     outf("[%d 0 0 -%d 0 %d]\n",ww,hh,hh);
941     outf("{currentfile picstr readhexstring pop}\n");
942     outf("false %d\n",3);
943     outf("colorimage\n");
944 
945     int end=ww*hh;
946     for(int i=0; i<end ; i+=4){
947       outhex(buffer[i]);
948       outhex(buffer[i+1]);
949       outhex(buffer[i+2]);
950       }
951     outf("\n");
952     }
953   }
954 
955 
956 // Draw bitmap
drawBitmap(const FXBitmap *,FXint,FXint)957 void FXDCPrint::drawBitmap(const FXBitmap*,FXint,FXint){
958   }
959 
960 
961 // Draw icon
drawIcon(const FXIcon *,FXint,FXint)962 void FXDCPrint::drawIcon(const FXIcon*,FXint,FXint){
963   }
964 
965 
966 // Draw icon shaded
drawIconShaded(const FXIcon *,FXint,FXint)967 void FXDCPrint::drawIconShaded(const FXIcon*,FXint,FXint){
968   }
969 
970 
971 // Draw icon sunken
drawIconSunken(const FXIcon *,FXint,FXint)972 void FXDCPrint::drawIconSunken(const FXIcon*,FXint,FXint){
973   }
974 
975 
976 // Draw hashed box
drawHashBox(FXint,FXint,FXint,FXint,FXint)977 void FXDCPrint::drawHashBox(FXint,FXint,FXint,FXint,FXint){
978   }
979 
980 
981 // Set foreground drawing color (brush)
setForeground(FXColor clr)982 void FXDCPrint::setForeground(FXColor clr){
983   outf("%g %g %g setrgbcolor\n",FXREDVAL(clr)/255.0,FXGREENVAL(clr)/255.0,FXBLUEVAL(clr)/255.0);
984   fg=clr;
985   }
986 
987 
988 // Set background drawing color (brush)
setBackground(FXColor clr)989 void FXDCPrint::setBackground(FXColor clr){
990   bg=clr;
991   }
992 
993 
994 // Set dash pattern
setDashes(FXuint,const FXchar *,FXuint)995 void FXDCPrint::setDashes(FXuint,const FXchar *,FXuint){
996   }
997 
998 
999 // Set line width
setLineWidth(FXuint linewidth)1000 void FXDCPrint::setLineWidth(FXuint linewidth){
1001   outf("%d setlinewidth\n",linewidth);
1002   width=linewidth;
1003   }
1004 
1005 
1006 // Set line cap style
setLineCap(FXCapStyle capstyle)1007 void FXDCPrint::setLineCap(FXCapStyle capstyle){
1008   FXint ncap=0;
1009 
1010   if(CAP_BUTT==capstyle) ncap=0;
1011   if(CAP_ROUND==capstyle) ncap=1;
1012   if(CAP_PROJECTING==capstyle) ncap=3;
1013 
1014   outf("%d setlinecap\n",ncap);
1015   cap=capstyle;
1016   }
1017 
1018 
1019 // Set line join style
setLineJoin(FXJoinStyle joinstyle)1020 void FXDCPrint::setLineJoin(FXJoinStyle joinstyle){
1021   join=joinstyle;
1022   }
1023 
1024 
1025 // Set line style
setLineStyle(FXLineStyle linestyle)1026 void FXDCPrint::setLineStyle(FXLineStyle linestyle){
1027   style=linestyle;
1028   }
1029 
1030 
1031 // Set fill style
setFillStyle(FXFillStyle fillstyle)1032 void FXDCPrint::setFillStyle(FXFillStyle fillstyle){
1033   fill=fillstyle;
1034   }
1035 
1036 
1037 // Set fill rule
setFillRule(FXFillRule fillrule)1038 void FXDCPrint::setFillRule(FXFillRule fillrule){
1039   rule=fillrule;
1040   }
1041 
1042 
1043 // Set blit function
setFunction(FXFunction func)1044 void FXDCPrint::setFunction(FXFunction func){
1045   rop=func;
1046   }
1047 
1048 
1049 // Set tile image
setTile(FXImage * image,FXint dx,FXint dy)1050 void FXDCPrint::setTile(FXImage* image,FXint dx,FXint dy){
1051   tile=image;
1052   tx=dx;
1053   ty=dy;
1054   }
1055 
1056 
1057 // Set stipple pattern
setStipple(FXBitmap * bitmap,FXint dx,FXint dy)1058 void FXDCPrint::setStipple(FXBitmap* bitmap,FXint dx,FXint dy){
1059   stipple=bitmap;
1060   pattern=STIPPLE_NONE;
1061   tx=dx;
1062   ty=dy;
1063   }
1064 
1065 
1066 // Set stipple pattern
setStipple(FXStipplePattern pat,FXint dx,FXint dy)1067 void FXDCPrint::setStipple(FXStipplePattern pat,FXint dx,FXint dy){
1068   stipple=NULL;
1069   pattern=pat;
1070   tx=dx;
1071   ty=dy;
1072   }
1073 
1074 
1075 // Set clip rectangle
setClipRectangle(FXint x,FXint y,FXint w,FXint h)1076 void FXDCPrint::setClipRectangle(FXint x,FXint y,FXint w,FXint h){
1077   clip.x=x;
1078   clip.y=y;
1079   clip.w=w;
1080   clip.h=h;
1081   }
1082 
1083 
1084 // Set clip rectangle
setClipRectangle(const FXRectangle & rectangle)1085 void FXDCPrint::setClipRectangle(const FXRectangle& rectangle){
1086   clip=rectangle;
1087   }
1088 
1089 
1090 // Clear clipping
clearClipRectangle()1091 void FXDCPrint::clearClipRectangle(){
1092   clip.x=0;
1093   clip.y=0;
1094   clip.w=32767;
1095   clip.h=32767;
1096   }
1097 
1098 
1099 // Set clip mask
setClipMask(FXBitmap * bitmap,FXint dx,FXint dy)1100 void FXDCPrint::setClipMask(FXBitmap* bitmap,FXint dx,FXint dy){
1101   mask=bitmap;
1102   cx=dx;
1103   cy=dy;
1104   }
1105 
1106 
1107 // Clear clip mask
clearClipMask()1108 void FXDCPrint::clearClipMask(){
1109   }
1110 
1111 
1112 
1113 // Set font to draw text with
setFont(FXFont * fnt)1114 void FXDCPrint::setFont(FXFont *fnt){
1115   font=fnt;
1116   }
1117 
1118 
1119 // Change clip-against-child windows mode
clipChildren(FXbool)1120 void FXDCPrint::clipChildren(FXbool){
1121   }
1122 
1123 
1124 
1125 
1126 /*
1127 
1128 Contrib by "Vasudeva Upadhya" <kvu@cfd1.cfdrc.com>
1129 FXint FXSetup::DoNTPrint(FXPrinter& printInfo){
1130 	PDEVMODE pDevMode = NULL;
1131 	LONG     lDevModeSize;
1132 	HANDLE   hDevMode = NULL;
1133 	HDC      pDC = NULL;
1134 	DOCINFO  docInfo;
1135 	FXString msg = FXString("License setup wizard was unable to print,\nto printer:")+FXString(printInfo.name);
1136 	FXint    xOrigin;
1137 	FXint    yOrigin;
1138 	FXint    xSize;
1139 	FXint    ySize;
1140 
1141 	lDevModeSize = DocumentProperties(NULL,NULL,printInfo.name,NULL,NULL,0);
1142 	if(lDevModeSize > 0){
1143 		hDevMode = GlobalAlloc(GHND,lDevModeSize);
1144 		pDevMode = (PDEVMODE)GlobalLock(hDevMode);
1145 		DocumentProperties(NULL,NULL,printInfo.name,pDevMode,NULL,DM_OUT_BUFFER);
1146 	  }
1147 	pDC = CreateDC("WINSPOOL",printInfo.name,NULL,pDevMode);
1148 	if(pDC){
1149 		xOrigin = GetDeviceCaps(pDC,PHYSICALOFFSETX);
1150 		yOrigin = GetDeviceCaps(pDC,PHYSICALOFFSETY);
1151 		xSize   = GetDeviceCaps(pDC,HORZRES);
1152 		ySize   = GetDeviceCaps(pDC,VERTRES);
1153 
1154 		docInfo.cbSize       = sizeof(DOCINFO);
1155 		docInfo.lpszDocName  = printInfo.name;
1156 		docInfo.lpszOutput   = NULL;
1157 		docInfo.lpszDatatype = NULL;
1158 		docInfo.fwType       = 0;
1159 
1160 		if(StartDoc(pDC,&docInfo)){
1161 			if(StartPage(pDC)){
1162 				FXint yPos  = yOrigin+200;
1163 				FXint x1Pos = xOrigin+50;
1164 				FXint x2Pos = xOrigin+600;
1165 				FXint n;
1166 
1167 				TextOut(pDC,x1Pos,yPos,"Customer Information:",strlen("Customer Information:"));
1168 				yPos = yPos+50;
1169 				for(n=0; n < sizeof(machineInfo)/sizeof(char*);n++){
1170 					TextOut(pDC,x1Pos,yPos,machineInfo[n],strlen(machineInfo[n]));
1171 					TextOut(pDC,x2Pos,yPos,lockID[n].text(),lockID[n].length());
1172 					yPos = yPos+50;
1173 				  }
1174 				yPos = yPos+50;
1175 				for(n=0; n < sizeof(CustomerInfo)/sizeof(char*);n++){
1176 					TextOut(pDC,x1Pos,yPos,CustomerInfo[n],strlen(CustomerInfo[n]));
1177 					TextOut(pDC,x2Pos,yPos,fieldTexts[n].text(),fieldTexts[n].length());
1178 					yPos = yPos+50;
1179 				  }
1180 				if(EndPage(pDC)){
1181 					if(EndDoc(pDC)){
1182 						GlobalFree((PDEVMODE)pDevMode);
1183 						GlobalFree((HANDLE)hDevMode);
1184 						DeleteDC(pDC);
1185 						return 1;
1186 					  }
1187 				  }
1188 			  }
1189 			else{
1190 				GlobalFree((PDEVMODE)pDevMode);
1191 				GlobalFree((HANDLE)hDevMode);
1192 				DeleteDC(pDC);
1193 				FXMessageBox::error(this,MBOX_OK,"Print Error",msg.text());
1194 				return 0;
1195 			  }
1196 		  }
1197 		else{
1198 			GlobalFree((PDEVMODE)pDevMode);
1199 			GlobalFree((HANDLE)hDevMode);
1200 			FXMessageBox::error(this,MBOX_OK,"Print Error",msg.text());
1201 			return 0;
1202 		  }
1203 	  }
1204 	else{
1205 		GlobalFree((PDEVMODE)pDevMode);
1206 		GlobalFree((HANDLE)hDevMode);
1207 		FXMessageBox::error(this,MBOX_OK,"Print Error",msg.text());
1208 		return 0;
1209 	  }
1210 	return 1;
1211   }
1212 
1213 */
1214 
1215 }
1216 
1217