fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_PostScript.cxx
Go to the documentation of this file.
1 //
2 // "$Id$"
3 //
4 // PostScript device support for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 2010-2015 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems to:
15 //
16 // http://www.fltk.org/str.php
17 //
18 
19 #include <FL/Fl_Printer.H>
20 #include <config.h>
21 #include <FL/Fl.H>
22 #include <FL/fl_ask.H>
23 #include <FL/fl_draw.H>
24 #include <stdio.h>
25 #include <FL/Fl_PostScript.H>
27 #include <stdarg.h>
28 #if defined(USE_X11)
29 #include "Fl_Font.H"
30 #if USE_XFT
31 #include <X11/Xft/Xft.h>
32 #endif
33 #endif
34 
35 const char *Fl_PostScript_Graphics_Driver::class_id = "Fl_PostScript_Graphics_Driver";
36 const char *Fl_PostScript_File_Device::class_id = "Fl_PostScript_File_Device";
38 const char *Fl_PostScript_File_Device::file_chooser_title = "Select a .ps file";
39 
44 {
45  close_cmd_ = 0;
46  //lang_level_ = 3;
47  lang_level_ = 2;
48  mask = 0;
50  scale_x = scale_y = 1.;
51  bg_r = bg_g = bg_b = 255;
52 }
53 
57 }
58 
63 {
64 #ifdef __APPLE__
65  gc = fl_gc; // the display context is used by fl_text_extents()
66 #endif
68 }
69 
74 {
76 }
77 
78 
89  enum Fl_Paged_Device::Page_Layout layout)
90 {
95  fnfc.filter("PostScript\t*.ps\n");
96  // Show native chooser
97  if ( fnfc.show() ) return 1;
99  ps->output = fl_fopen(fnfc.filename(), "w");
100  if(ps->output == NULL) return 2;
101  ps->ps_filename_ = strdup(fnfc.filename());
102  ps->start_postscript(pagecount, format, layout);
103  this->set_current();
104  return 0;
105 }
106 
107 extern "C" {
108  static int dont_close(FILE *f)
109  {
110  return 0;
111  }
112 }
113 
124 int Fl_PostScript_File_Device::start_job (FILE *ps_output, int pagecount,
126 {
128  ps->output = ps_output;
129  ps->ps_filename_ = NULL;
130  ps->start_postscript(pagecount, format, layout);
131  ps->close_command(dont_close); // so that end_job() doesn't close the file
132  this->set_current();
133  return 0;
134 }
135 
137 int Fl_PostScript_File_Device::start_job(int pagecount, int* from, int* to)
138 {
139  return 1;
140 }
141 
147  if (ps) delete ps;
148 }
149 
157 {
158  char *saved_locale = setlocale(LC_NUMERIC, NULL);
159  setlocale(LC_NUMERIC, "C");
160  va_list args;
161  va_start(args, format);
162  int retval = vfprintf(output, format, args);
163  va_end(args);
164  setlocale(LC_NUMERIC, saved_locale);
165  return retval;
166 }
167 
168 #ifndef FL_DOXYGEN
169 
170 #if ! (defined(__APPLE__) || defined(WIN32) )
171 # include "print_panel.cxx"
172 #endif
173 
174 // Prolog string
175 
176 static const char * prolog =
177 "%%BeginProlog\n"
178 "/L { /y2 exch def\n"
179 "/x2 exch def\n"
180 "/y1 exch def\n"
181 "/x1 exch def\n"
182 "newpath x1 y1 moveto x2 y2 lineto\n"
183 "stroke}\n"
184 "bind def\n"
185 
186 
187 "/R { /dy exch def\n"
188 "/dx exch def\n"
189 "/y exch def\n"
190 "/x exch def\n"
191 "newpath\n"
192 "x y moveto\n"
193 "dx 0 rlineto\n"
194 "0 dy rlineto\n"
195 "dx neg 0 rlineto\n"
196 "closepath stroke\n"
197 "} bind def\n"
198 
199 "/CL {\n"
200 "/dy exch def\n"
201 "/dx exch def\n"
202 "/y exch def\n"
203 "/x exch def\n"
204 "newpath\n"
205 "x y moveto\n"
206 "dx 0 rlineto\n"
207 "0 dy rlineto\n"
208 "dx neg 0 rlineto\n"
209 "closepath\n"
210 "clip\n"
211 "} bind def\n"
212 
213 "/FR { /dy exch def\n"
214 "/dx exch def\n"
215 "/y exch def\n"
216 "/x exch def\n"
217 "currentlinewidth 0 setlinewidth newpath\n"
218 "x y moveto\n"
219 "dx 0 rlineto\n"
220 "0 dy rlineto\n"
221 "dx neg 0 rlineto\n"
222 "closepath fill setlinewidth\n"
223 "} bind def\n"
224 
225 "/GS { gsave } bind def\n"
226 "/GR { grestore } bind def\n"
227 
228 "/SP { showpage } bind def\n"
229 "/LW { setlinewidth } bind def\n"
230 "/CF /Courier def\n"
231 "/SF { /CF exch def } bind def\n"
232 "/fsize 12 def\n"
233 "/FS { /fsize exch def fsize CF findfont exch scalefont setfont }def \n"
234 
235 
236 "/GL { setgray } bind def\n"
237 "/SRGB { setrgbcolor } bind def\n"
238 
239 "/A85RLE { /ASCII85Decode filter /RunLengthDecode filter } bind def\n" // ASCII85Decode followed by RunLengthDecode filters
240 
241 // color images
242 
243 "/CI { GS /py exch def /px exch def /sy exch def /sx exch def\n"
244 "translate \n"
245 "sx sy scale px py 8 \n"
246 "[ px 0 0 py neg 0 py ]\n"
247 "currentfile A85RLE\n false 3"
248 " colorimage GR\n"
249 "} bind def\n"
250 
251 // gray images
252 
253 "/GI { GS /py exch def /px exch def /sy exch def /sx exch def \n"
254 "translate \n"
255 "sx sy scale px py 8 \n"
256 
257 
258 "[ px 0 0 py neg 0 py ]\n"
259 "currentfile A85RLE\n"
260 "image GR\n"
261 "} bind def\n"
262 
263 // single-color bitmask
264 
265 "/MI { GS /py exch def /px exch def /sy exch def /sx exch def \n"
266 "translate \n"
267 "sx sy scale px py true \n"
268 "[ px 0 0 py neg 0 py ]\n"
269 "currentfile A85RLE\n"
270 "imagemask GR\n"
271 "} bind def\n"
272 
273 
274 // path
275 
276 "/BFP { newpath moveto } def\n"
277 "/BP { newpath } bind def \n"
278 "/PL { lineto } bind def \n"
279 "/PM { moveto } bind def \n"
280 "/MT { moveto } bind def \n"
281 "/LT { lineto } bind def \n"
282 "/EFP { closepath fill } bind def\n" //was:stroke
283 "/ELP { stroke } bind def\n"
284 "/ECP { closepath stroke } bind def\n" // Closed (loop)
285 "/LW { setlinewidth } bind def\n"
286 
287 // ////////////////////////// misc ////////////////
288 "/TR { translate } bind def\n"
289 "/CT { concat } bind def\n"
290 "/RCT { matrix invertmatrix concat} bind def\n"
291 "/SC { scale } bind def\n"
292 //"/GPD { currentpagedevice /PageSize get} def\n"
293 
294 // show at position with desired width
295 // usage:
296 // width (string) x y show_pos_width
297 "/show_pos_width {GS moveto dup dup stringwidth pop exch length 2 div dup 2 le {pop 9999} if "
298 "1 sub exch 3 index exch sub exch "
299 "div 0 2 index 1 -1 scale ashow pop pop GR} bind def\n" // spacing altered to match desired width
300 //"/show_pos_width {GS moveto dup stringwidth pop 3 2 roll exch div -1 matrix scale concat "
301 //"show GR } bind def\n" // horizontally scaled text to match desired width
302 
303 ;
304 
305 
306 static const char * prolog_2 = // prolog relevant only if lang_level >1
307 
308 // color image dictionaries
309 "/CII {GS /inter exch def /py exch def /px exch def /sy exch def /sx exch def \n"
310 "translate \n"
311 "sx sy scale\n"
312 "/DeviceRGB setcolorspace\n"
313 "/IDD 8 dict def\n"
314 "IDD begin\n"
315 "/ImageType 1 def\n"
316 "/Width px def\n"
317 "/Height py def\n"
318 "/BitsPerComponent 8 def\n"
319 "/Interpolate inter def\n"
320 "/DataSource currentfile A85RLE def\n"
321 "/MultipleDataSources false def\n"
322 "/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
323 "/Decode [ 0 1 0 1 0 1 ] def\n"
324 "end\n"
325 "IDD image GR} bind def\n"
326 
327 // gray image dict
328 "/GII {GS /inter exch def /py exch def /px exch def /sy exch def /sx exch def \n"
329 "translate \n"
330 "sx sy scale\n"
331 "/DeviceGray setcolorspace\n"
332 "/IDD 8 dict def\n"
333 "IDD begin\n"
334 "/ImageType 1 def\n"
335 "/Width px def\n"
336 "/Height py def\n"
337 "/BitsPerComponent 8 def\n"
338 
339 "/Interpolate inter def\n"
340 "/DataSource currentfile A85RLE def\n"
341 "/MultipleDataSources false def\n"
342 "/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
343 "/Decode [ 0 1 ] def\n"
344 "end\n"
345 "IDD image GR} bind def\n"
346 
347 // Create a custom PostScript font derived from PostScript standard text fonts
348 // The encoding of this custom font is as follows:
349 // 0000-00FF coincides with Unicode, that is to ASCII + Latin-1
350 // 0100-017F coincides with Unicode, that is to Latin Extended-A
351 // 0180-01A6 encodes miscellaneous characters present in PostScript standard text fonts
352 
353 // use ISOLatin1Encoding for all text fonts
354 "/ToISO { dup findfont dup length dict copy begin /Encoding ISOLatin1Encoding def currentdict end definefont pop } def\n"
355 "/Helvetica ToISO /Helvetica-Bold ToISO /Helvetica-Oblique ToISO /Helvetica-BoldOblique ToISO \n"
356 "/Courier ToISO /Courier-Bold ToISO /Courier-Oblique ToISO /Courier-BoldOblique ToISO \n"
357 "/Times-Roman ToISO /Times-Bold ToISO /Times-Italic ToISO /Times-BoldItalic ToISO \n"
358 
359 // define LatinExtA, the encoding of Latin-extended-A + some additional characters
360 // see http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt for their names
361 "/LatinExtA \n"
362 "[ "
363 " /Amacron /amacron /Abreve /abreve /Aogonek /aogonek\n" // begin of Latin Extended-A code page
364 " /Cacute /cacute /Ccircumflex /ccircumflex /Cdotaccent /cdotaccent /Ccaron /ccaron \n"
365 " /Dcaron /dcaron /Dcroat /dcroat\n"
366 " /Emacron /emacron /Ebreve /ebreve /Edotaccent /edotaccent /Eogonek /eogonek /Ecaron /ecaron\n"
367 " /Gcircumflex /gcircumflex /Gbreve /gbreve /Gdotaccent /gdotaccent /Gcommaaccent /gcommaaccent \n"
368 " /Hcircumflex /hcircumflex /Hbar /hbar \n"
369 " /Itilde /itilde /Imacron /imacron /Ibreve /ibreve /Iogonek /iogonek /Idotaccent /dotlessi \n"
370 " /IJ /ij /Jcircumflex /jcircumflex\n"
371 " /Kcommaaccent /kcommaaccent /kgreenlandic \n"
372 " /Lacute /lacute /Lcommaaccent /lcommaaccent /Lcaron /lcaron /Ldotaccent /ldotaccent /Lslash /lslash \n"
373 " /Nacute /nacute /Ncommaaccent /ncommaaccent /Ncaron /ncaron /napostrophe /Eng /eng \n"
374 " /Omacron /omacron /Obreve /obreve /Ohungarumlaut /ohungarumlaut /OE /oe \n"
375 " /Racute /racute /Rcommaaccent /rcommaaccent /Rcaron /rcaron \n"
376 " /Sacute /sacute /Scircumflex /scircumflex /Scedilla /scedilla /Scaron /scaron \n"
377 " /Tcommaaccent /tcommaaccent /Tcaron /tcaron /Tbar /tbar \n"
378 " /Utilde /utilde /Umacron /umacron /Ubreve /ubreve /Uring /uring /Uhungarumlaut /uhungarumlaut /Uogonek /uogonek \n"
379 " /Wcircumflex /wcircumflex /Ycircumflex /ycircumflex /Ydieresis \n"
380 " /Zacute /zacute /Zdotaccent /zdotaccent /Zcaron /zcaron \n"
381 " /longs \n" // end of Latin Extended-A code page
382 " /florin /circumflex /caron /breve /dotaccent /ring \n" // remaining characters from PostScript standard text fonts
383 " /ogonek /tilde /hungarumlaut /endash /emdash \n"
384 " /quoteleft /quoteright /quotesinglbase /quotedblleft /quotedblright \n"
385 " /quotedblbase /dagger /daggerdbl /bullet /ellipsis \n"
386 " /perthousand /guilsinglleft /guilsinglright /fraction /Euro \n"
387 " /trademark /partialdiff /Delta /summation /radical \n"
388 " /infinity /notequal /lessequal /greaterequal /lozenge \n"
389 " /fi /fl /apple \n"
390 " ] def \n"
391 // deal with alternative PostScript names of some characters
392 " /mycharstrings /Helvetica findfont /CharStrings get def\n"
393 " /PSname2 { dup mycharstrings exch known {LatinExtA 3 -1 roll 3 -1 roll put}{pop pop} ifelse } def \n"
394 " 16#20 /Gdot PSname2 16#21 /gdot PSname2 16#30 /Idot PSname2 16#3F /Ldot PSname2 16#40 /ldot PSname2 16#7F /slong PSname2 \n"
395 
396 // proc that gives LatinExtA encoding to a font
397 "/ToLatinExtA { findfont dup length dict copy begin /Encoding LatinExtA def currentdict end definefont pop } def\n"
398 // create Ext-versions of standard fonts that use LatinExtA encoding \n"
399 "/HelveticaExt /Helvetica ToLatinExtA \n"
400 "/Helvetica-BoldExt /Helvetica-Bold ToLatinExtA /Helvetica-ObliqueExt /Helvetica-Oblique ToLatinExtA \n"
401 "/Helvetica-BoldObliqueExt /Helvetica-BoldOblique ToLatinExtA \n"
402 "/CourierExt /Courier ToLatinExtA /Courier-BoldExt /Courier-Bold ToLatinExtA \n"
403 "/Courier-ObliqueExt /Courier-Oblique ToLatinExtA /Courier-BoldObliqueExt /Courier-BoldOblique ToLatinExtA \n"
404 "/Times-RomanExt /Times-Roman ToLatinExtA /Times-BoldExt /Times-Bold ToLatinExtA \n"
405 "/Times-ItalicExt /Times-Italic ToLatinExtA /Times-BoldItalicExt /Times-BoldItalic ToLatinExtA \n"
406 
407 // proc to create a Type 0 font with 2-byte encoding
408 // that merges a text font with ISO encoding + same font with LatinExtA encoding
409 "/To2byte { 6 dict begin /FontType 0 def \n"
410 "/FDepVector 3 1 roll findfont exch findfont 2 array astore def \n"
411 "/FontMatrix [1 0 0 1 0 0] def /FMapType 6 def /Encoding [ 0 1 0 ] def\n"
412 // 100: Hexa count of ISO array; A7: hexa count of LatinExtA array
413 "/SubsVector < 01 0100 00A7 > def\n"
414 "currentdict end definefont pop } def\n"
415 // create Type 0 versions of standard fonts
416 "/Helvetica2B /HelveticaExt /Helvetica To2byte \n"
417 "/Helvetica-Bold2B /Helvetica-BoldExt /Helvetica-Bold To2byte \n"
418 "/Helvetica-Oblique2B /Helvetica-ObliqueExt /Helvetica-Oblique To2byte \n"
419 "/Helvetica-BoldOblique2B /Helvetica-BoldObliqueExt /Helvetica-BoldOblique To2byte \n"
420 "/Courier2B /CourierExt /Courier To2byte \n"
421 "/Courier-Bold2B /Courier-BoldExt /Courier-Bold To2byte \n"
422 "/Courier-Oblique2B /Courier-ObliqueExt /Courier-Oblique To2byte \n"
423 "/Courier-BoldOblique2B /Courier-BoldObliqueExt /Courier-BoldOblique To2byte \n"
424 "/Times-Roman2B /Times-RomanExt /Times-Roman To2byte \n"
425 "/Times-Bold2B /Times-BoldExt /Times-Bold To2byte \n"
426 "/Times-Italic2B /Times-ItalicExt /Times-Italic To2byte \n"
427 "/Times-BoldItalic2B /Times-BoldItalicExt /Times-BoldItalic To2byte \n"
428 ;
429 
430 static const char * prolog_2_pixmap = // prolog relevant only if lang_level == 2 for pixmaps/masked color images
431 "/pixmap_mat {[ pixmap_sx 0 0 pixmap_sy neg 0 pixmap_sy ]} bind def\n"
432 
433 "/pixmap_dict {"
434 "<< /PatternType 1 "
435 "/PaintType 1 "
436 "/TilingType 2 "
437 "/BBox [0 0 pixmap_sx pixmap_sy] "
438 "/XStep pixmap_sx "
439 "/YStep pixmap_sy\n"
440 "/PaintProc "
441 "{ begin "
442 "pixmap_w pixmap_h scale "
443 "pixmap_sx pixmap_sy 8 "
444 "pixmap_mat "
445 "currentfile A85RLE "
446 "false 3 "
447 "colorimage "
448 "end "
449 "} bind "
450 ">>\n"
451 "} bind def\n"
452 
453 "/pixmap_plot {"
454 "GS "
455 "/pixmap_sy exch def /pixmap_sx exch def\n"
456 "/pixmap_h exch def /pixmap_w exch def\n"
457 "translate\n"
458 "pixmap_dict matrix makepattern setpattern\n"
459 "pixmap_w pixmap_h scale\n"
460 "pixmap_sx pixmap_sy\n"
461 "true\n"
462 "pixmap_mat\n"
463 "currentfile A85RLE\n"
464 "imagemask\n"
465 "GR\n"
466 "} bind def\n"
467 ;
468 
469 static const char * prolog_3 = // prolog relevant only if lang_level >2
470 
471 // masked color images
472 "/CIM {GS /inter exch def /my exch def /mx exch def /py exch def /px exch def /sy exch def /sx exch def \n"
473 "translate \n"
474 "sx sy scale\n"
475 "/DeviceRGB setcolorspace\n"
476 
477 "/IDD 8 dict def\n"
478 
479 "IDD begin\n"
480 "/ImageType 1 def\n"
481 "/Width px def\n"
482 "/Height py def\n"
483 "/BitsPerComponent 8 def\n"
484 "/Interpolate inter def\n"
485 "/DataSource currentfile A85RLE def\n"
486 "/MultipleDataSources false def\n"
487 "/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
488 
489 "/Decode [ 0 1 0 1 0 1 ] def\n"
490 "end\n"
491 
492 "/IMD 8 dict def\n"
493 "IMD begin\n"
494 "/ImageType 1 def\n"
495 "/Width mx def\n"
496 "/Height my def\n"
497 "/BitsPerComponent 1 def\n"
498 // "/Interpolate inter def\n"
499 "/ImageMatrix [ mx 0 0 my neg 0 my ] def\n"
500 "/Decode [ 1 0 ] def\n"
501 "end\n"
502 
503 "<<\n"
504 "/ImageType 3\n"
505 "/InterleaveType 2\n"
506 "/MaskDict IMD\n"
507 "/DataDict IDD\n"
508 ">> image GR\n"
509 "} bind def\n"
510 
511 
512 // masked gray images
513 "/GIM {GS /inter exch def /my exch def /mx exch def /py exch def /px exch def /sy exch def /sx exch def \n"
514 "translate \n"
515 "sx sy scale\n"
516 "/DeviceGray setcolorspace\n"
517 
518 "/IDD 8 dict def\n"
519 
520 "IDD begin\n"
521 "/ImageType 1 def\n"
522 "/Width px def\n"
523 "/Height py def\n"
524 "/BitsPerComponent 8 def\n"
525 "/Interpolate inter def\n"
526 "/DataSource currentfile A85RLE def\n"
527 "/MultipleDataSources false def\n"
528 "/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
529 
530 "/Decode [ 0 1 ] def\n"
531 "end\n"
532 
533 "/IMD 8 dict def\n"
534 
535 "IMD begin\n"
536 "/ImageType 1 def\n"
537 "/Width mx def\n"
538 "/Height my def\n"
539 "/BitsPerComponent 1 def\n"
540 "/ImageMatrix [ mx 0 0 my neg 0 my ] def\n"
541 "/Decode [ 1 0 ] def\n"
542 "end\n"
543 
544 "<<\n"
545 "/ImageType 3\n"
546 "/InterleaveType 2\n"
547 "/MaskDict IMD\n"
548 "/DataDict IDD\n"
549 ">> image GR\n"
550 "} bind def\n"
551 
552 
553 "\n"
554 ;
555 
556 // end prolog
557 
560 //returns 0 iff OK
561 {
562  int w, h, x;
563  if (format == Fl_Paged_Device::A4) {
564  left_margin = 18;
565  top_margin = 18;
566  }
567  else {
568  left_margin = 12;
569  top_margin = 12;
570  }
571  page_format_ = (enum Fl_Paged_Device::Page_Format)(format | layout);
572  if (layout & Fl_Paged_Device::LANDSCAPE){
575  } else {
578  }
579 
580  fputs("%!PS-Adobe-3.0\n", output);
581  fputs("%%Creator: FLTK\n", output);
582  if (lang_level_>1)
583  fprintf(output, "%%%%LanguageLevel: %i\n" , lang_level_);
584  if ((pages_ = pagecount))
585  fprintf(output, "%%%%Pages: %i\n", pagecount);
586  else
587  fputs("%%Pages: (atend)\n", output);
588  fprintf(output, "%%%%BeginFeature: *PageSize %s\n", Fl_Paged_Device::page_formats[format].name );
591  if (lang_level_ == 3 && (layout & Fl_Paged_Device::LANDSCAPE) ) { x = w; w = h; h = x; }
592  fprintf(output, "<</PageSize[%d %d]>>setpagedevice\n", w, h );
593  fputs("%%EndFeature\n", output);
594  fputs("%%EndComments\n", output);
595  fputs(prolog, output);
596  if (lang_level_ > 1) {
597  fputs(prolog_2, output);
598  }
599  if (lang_level_ == 2) {
600  fputs(prolog_2_pixmap, output);
601  }
602  if (lang_level_ > 2)
603  fputs(prolog_3, output);
604  if (lang_level_ >= 3) {
605  fputs("/CS { clipsave } bind def\n", output);
606  fputs("/CR { cliprestore } bind def\n", output);
607  } else {
608  fputs("/CS { GS } bind def\n", output);
609  fputs("/CR { GR } bind def\n", output);
610  }
611  page_policy_ = 1;
612 
613 
614  fputs("%%EndProlog\n",output);
615  if (lang_level_ >= 2)
616  fprintf(output,"<< /Policies << /Pagesize 1 >> >> setpagedevice\n");
617 
618  reset();
619  nPages=0;
620  return 0;
621 }
622 
624  color(cr_,cg_,cb_);
627 }
628 
630  gap_=1;
631  clip_=0;
632  cr_=cg_=cb_=0;
634  linewidth_=0;
636  strcpy(linedash_,"");
637  Clip *c=clip_;
638 
639  while(c){
640  clip_=clip_->prev;
641  delete c;
642  c=clip_;
643  }
644 
645 }
646 
648  page_policy_ = p;
649  if(lang_level_>=2)
650  fprintf(output,"<< /Policies << /Pagesize %i >> >> setpagedevice\n", p);
651 }
652 
653 // //////////////////// paging //////////////////////////////////////////
654 
655 
656 
657 void Fl_PostScript_Graphics_Driver::page(double pw, double ph, int media) {
658 
659  if (nPages){
660  fprintf(output, "CR\nGR\nGR\nGR\nSP\nrestore\n");
661  }
662  ++nPages;
663  fprintf(output, "%%%%Page: %i %i\n" , nPages , nPages);
664  fprintf(output, "%%%%PageBoundingBox: 0 0 %d %d\n", pw > ph ? (int)ph : (int)pw , pw > ph ? (int)pw : (int)ph);
665  if (pw>ph){
666  fprintf(output, "%%%%PageOrientation: Landscape\n");
667  }else{
668  fprintf(output, "%%%%PageOrientation: Portrait\n");
669  }
670 
671  fprintf(output, "%%%%BeginPageSetup\n");
672  if((media & Fl_Paged_Device::MEDIA) &&(lang_level_>1)){
673  int r = media & Fl_Paged_Device::REVERSED;
674  if(r) r = 2;
675  fprintf(output, "<< /PageSize [%i %i] /Orientation %i>> setpagedevice\n", (int)(pw+.5), (int)(ph+.5), r);
676  }
677  fprintf(output, "%%%%EndPageSetup\n");
678 
679 /* pw_ = pw;
680  ph_ = ph;*/
681  reset();
682 
683  fprintf(output, "save\n");
684  fprintf(output, "GS\n");
685  clocale_printf( "%g %g TR\n", (double)0 /*lm_*/ , ph_ /* - tm_*/);
686  fprintf(output, "1 -1 SC\n");
687  line_style(0);
688  fprintf(output, "GS\n");
689 
690  if (!((media & Fl_Paged_Device::MEDIA) &&(lang_level_>1))){
691  if (pw > ph) {
692  if(media & Fl_Paged_Device::REVERSED) {
693  fprintf(output, "-90 rotate %i 0 translate\n", int(-pw));
694  }
695  else {
696  fprintf(output, "90 rotate -%i -%i translate\n", (lang_level_ == 2 ? int(pw - ph) : 0), int(ph));
697  }
698  }
699  else {
700  if(media & Fl_Paged_Device::REVERSED)
701  fprintf(output, "180 rotate %i %i translate\n", int(-pw), int(-ph));
702  }
703  }
704  fprintf(output, "GS\nCS\n");
705 }
706 
708 /* if(format & Fl_Paged_Device::LANDSCAPE){
709  ph_=Fl_Paged_Device::page_formats[format & 0xFF].width;
710  pw_=Fl_Paged_Device::page_formats[format & 0xFF].height;
711  }else{
712  pw_=Fl_Paged_Device::page_formats[format & 0xFF].width;
713  ph_=Fl_Paged_Device::page_formats[format & 0xFF].height;
714  }*/
715  page(pw_,ph_,format & 0xFF00);//,orientation only;
716 }
717 
718 void Fl_PostScript_Graphics_Driver::rect(int x, int y, int w, int h) {
719  // Commented code does not work, i can't find the bug ;-(
720  // fprintf(output, "GS\n");
721  // fprintf(output, "%i, %i, %i, %i R\n", x , y , w, h);
722  // fprintf(output, "GR\n");
723  fprintf(output, "GS\n");
724  fprintf(output,"BP\n");
725  fprintf(output, "%i %i MT\n", x , y);
726  fprintf(output, "%i %i LT\n", x+w-1 , y);
727  fprintf(output, "%i %i LT\n", x+w-1 , y+h-1);
728  fprintf(output, "%i %i LT\n", x , y+h-1);
729  fprintf(output, "ECP\n");
730  fprintf(output, "GR\n");
731 }
732 
733 void Fl_PostScript_Graphics_Driver::rectf(int x, int y, int w, int h) {
734  clocale_printf( "%g %g %i %i FR\n", x-0.5, y-0.5, w, h);
735 }
736 
737 void Fl_PostScript_Graphics_Driver::line(int x1, int y1, int x2, int y2) {
738  fprintf(output, "GS\n");
739  fprintf(output, "%i %i %i %i L\n", x1 , y1, x2 ,y2);
740  fprintf(output, "GR\n");
741 }
742 
743 void Fl_PostScript_Graphics_Driver::line(int x0, int y0, int x1, int y1, int x2, int y2) {
744  fprintf(output, "GS\n");
745  fprintf(output,"BP\n");
746  fprintf(output, "%i %i MT\n", x0 , y0);
747  fprintf(output, "%i %i LT\n", x1 , y1);
748  fprintf(output, "%i %i LT\n", x2 , y2);
749  fprintf(output, "ELP\n");
750  fprintf(output, "GR\n");
751 }
752 
753 void Fl_PostScript_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3){
754  fprintf(output, "GS\n");
755  fprintf(output,"BP\n");
756  fprintf(output, "%i %i MT\n", x , y );
757  fprintf(output, "%i %i LT\n", x1 , y );
758  fprintf(output, "%i %i LT\n", x1 , y2);
759  fprintf(output,"%i %i LT\n", x3 , y2);
760  fprintf(output, "ELP\n");
761  fprintf(output, "GR\n");
762 }
763 
764 
765 void Fl_PostScript_Graphics_Driver::xyline(int x, int y, int x1, int y2){
766 
767  fprintf(output, "GS\n");
768  fprintf(output,"BP\n");
769  fprintf(output, "%i %i MT\n", x , y);
770  fprintf(output,"%i %i LT\n", x1 , y);
771  fprintf(output, "%i %i LT\n", x1 , y2 );
772  fprintf(output, "ELP\n");
773  fprintf(output, "GR\n");
774 }
775 
777  fprintf(output, "GS\n");
778  fprintf(output,"BP\n");
779  fprintf(output, "%i %i MT\n", x , y);
780  fprintf(output, "%i %i LT\n", x1 , y );
781  fprintf(output, "ELP\n");
782 
783  fprintf(output, "GR\n");
784 }
785 
786 void Fl_PostScript_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3){
787  fprintf(output, "GS\n");
788 
789  fprintf(output,"BP\n");
790  fprintf(output,"%i %i MT\n", x , y);
791  fprintf(output, "%i %i LT\n", x , y1 );
792  fprintf(output, "%i %i LT\n", x2 , y1 );
793  fprintf(output , "%i %i LT\n", x2 , y3);
794  fprintf(output, "ELP\n");
795  fprintf(output, "GR\n");
796 }
797 
798 void Fl_PostScript_Graphics_Driver::yxline(int x, int y, int y1, int x2){
799  fprintf(output, "GS\n");
800  fprintf(output,"BP\n");
801  fprintf(output, "%i %i MT\n", x , y);
802  fprintf(output, "%i %i LT\n", x , y1);
803  fprintf(output, "%i %i LT\n", x2 , y1);
804  fprintf(output, "ELP\n");
805  fprintf(output, "GR\n");
806 }
807 
809  fprintf(output, "GS\n");
810  fprintf(output,"BP\n");
811  fprintf(output, "%i %i MT\n", x , y);
812  fprintf(output, "%i %i LT\n", x , y1);
813  fprintf(output, "ELP\n");
814  fprintf(output, "GR\n");
815 }
816 
817 void Fl_PostScript_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
818  fprintf(output, "GS\n");
819  fprintf(output,"BP\n");
820  fprintf(output, "%i %i MT\n", x0 , y0);
821  fprintf(output, "%i %i LT\n", x1 , y1);
822  fprintf(output, "%i %i LT\n", x2 , y2);
823  fprintf(output, "ECP\n");
824  fprintf(output, "GR\n");
825 }
826 
827 void Fl_PostScript_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
828  fprintf(output, "GS\n");
829  fprintf(output,"BP\n");
830  fprintf(output, "%i %i MT\n", x0 , y0);
831  fprintf(output, "%i %i LT\n", x1 , y1);
832  fprintf(output, "%i %i LT\n", x2 , y2);
833  fprintf(output, "%i %i LT\n", x3 , y3);
834  fprintf(output, "ECP\n");
835  fprintf(output, "GR\n");
836 }
837 
838 void Fl_PostScript_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
839  fprintf(output, "GS\n");
840  fprintf(output,"BP\n");
841  fprintf(output, "%i %i MT\n", x0 , y0);
842  fprintf(output,"%i %i LT\n", x1 , y1);
843  fprintf(output, "%i %i LT\n", x2 , y2);
844  fprintf(output, "EFP\n");
845  fprintf(output, "GR\n");
846 }
847 
848 void Fl_PostScript_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
849  fprintf(output, "GS\n");
850  fprintf(output,"BP\n");
851  fprintf(output, "%i %i MT\n", x0 , y0 );
852  fprintf(output, "%i %i LT\n", x1 , y1 );
853  fprintf(output, "%i %i LT\n", x2 , y2 );
854  fprintf(output, "%i %i LT\n", x3 , y3 );
855 
856  fprintf(output, "EFP\n");
857  fprintf(output, "GR\n");
858 }
859 
861  rectf(x,y,1,1);
862 }
863 
864 static const int dashes_flat[5][7]={
865 {-1,0,0,0,0,0,0},
866 {3,1,-1,0,0,0,0},
867 {1,1,-1,0,0,0,0},
868 {3,1,1,1,-1,0,0},
869 {3,1,1,1,1,1,-1}
870 };
871 
872 
873 //yeah, hack...
874 static const double dashes_cap[5][7]={
875 {-1,0,0,0,0,0,0},
876 {2,2,-1,0,0,0,0},
877 {0.01,1.99,-1,0,0,0,0},
878 {2,2,0.01,1.99,-1,0,0},
879 {2,2,0.01,1.99,0.01,1.99,-1}
880 };
881 
882 
883 void Fl_PostScript_Graphics_Driver::line_style(int style, int width, char* dashes){
884  //line_styled_=1;
885 
887  linestyle_=style;
888  //dashes_= dashes;
889  if(dashes){
890  if(dashes != linedash_)
891  strcpy(linedash_,dashes);
892 
893  }else
894  linedash_[0]=0;
895  char width0 = 0;
896  if(!width){
897  width=1; //for screen drawing compatibility
898  width0=1;
899  }
900 
901  fprintf(output, "%i setlinewidth\n", width);
902 
903  if(!style && (!dashes || !(*dashes)) && width0) //system lines
904  style = FL_CAP_SQUARE;
905 
906  int cap = (style &0xf00) >> 8;
907  if(cap) cap--;
908  fprintf(output,"%i setlinecap\n", cap);
909 
910  int join = (style & 0xf000) >> 12;
911 
912  if(join) join--;
913  fprintf(output,"%i setlinejoin\n", join);
914 
915 
916  fprintf(output, "[");
917  if(dashes && *dashes){
918  while(*dashes){
919  fprintf(output, "%i ", *dashes);
920  dashes++;
921  }
922  }else{
923  if(style & 0x200){ // round and square caps, dash length need to be adjusted
924  const double *dt = dashes_cap[style & 0xff];
925  while (*dt >= 0){
926  clocale_printf("%g ",width * (*dt));
927  dt++;
928  }
929  }else{
930 
931  const int *ds = dashes_flat[style & 0xff];
932  while (*ds >= 0){
933  fprintf(output, "%i ",width * (*ds));
934  ds++;
935  }
936  }
937  }
938  fprintf(output, "] 0 setdash\n");
939 }
940 
941 static const char *_fontNames[] = {
942 "Helvetica2B",
943 "Helvetica-Bold2B",
944 "Helvetica-Oblique2B",
945 "Helvetica-BoldOblique2B",
946 "Courier2B",
947 "Courier-Bold2B",
948 "Courier-Oblique2B",
949 "Courier-BoldOblique2B",
950 "Times-Roman2B",
951 "Times-Bold2B",
952 "Times-Italic2B",
953 "Times-BoldItalic2B",
954 "Symbol",
955 "Courier2B",
956 "Courier-Bold2B",
957 "ZapfDingbats"
958 };
959 
962  driver->font(f,s); // Use display fonts for font measurement
964  Fl_Font_Descriptor *desc = driver->font_descriptor();
965  this->font_descriptor(desc);
966  if (f < FL_FREE_FONT) {
967  float ps_size = (float) s;
968  fprintf(output, "/%s SF\n" , _fontNames[f]);
969 #if defined(USE_X11)
970 #if USE_XFT
971  // Xft font height is sometimes larger than the required size (see STR 2566).
972  // Increase the PostScript font size by 15% without exceeding the display font height
973  int max = desc->font->height;
974  ps_size = s * 1.15;
975  if (ps_size > max) ps_size = max;
976 #else
977  // Non-Xft fonts can be smaller than required.
978  // Set the PostScript font size to the display font height
979  char *name = desc->font->font_name_list[0];
980  char *p = strstr(name, "--");
981  if (p) {
982  sscanf(p + 2, "%f", &ps_size);
983  }
984 #endif // USE_XFT
985 #endif // USE_X11
986  clocale_printf("%.1f FS\n", ps_size);
987  }
988 }
989 
990 double Fl_PostScript_Graphics_Driver::width(const char *s, int n) {
991  return Fl_Display_Device::display_device()->driver()->width(s, n);
992 }
993 
994 double Fl_PostScript_Graphics_Driver::width(unsigned u) {
995  return Fl_Display_Device::display_device()->driver()->width(u);
996 }
997 
999  return Fl_Display_Device::display_device()->driver()->height();
1000 }
1001 
1003  return Fl_Display_Device::display_device()->driver()->descent();
1004 }
1005 
1006 void Fl_PostScript_Graphics_Driver::text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h) {
1007  Fl_Display_Device::display_device()->driver()->text_extents(c, n, dx, dy, w, h);
1008 }
1009 
1010 
1012  Fl::get_color(c, cr_, cg_, cb_);
1013  color(cr_, cg_, cb_);
1014 }
1015 
1016 void Fl_PostScript_Graphics_Driver::color(unsigned char r, unsigned char g, unsigned char b) {
1018  cr_ = r; cg_ = g; cb_ = b;
1019  if (r == g && g == b) {
1020  double gray = r/255.0;
1021  clocale_printf("%g GL\n", gray);
1022  } else {
1023  double fr, fg, fb;
1024  fr = r/255.0;
1025  fg = g/255.0;
1026  fb = b/255.0;
1027  clocale_printf("%g %g %g SRGB\n", fr , fg , fb);
1028  }
1029 }
1030 
1031 void Fl_PostScript_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y)
1032 {
1033  fprintf(output, "GS %d %d translate %d rotate\n", x, y, - angle);
1034  this->transformed_draw(str, n, 0, 0);
1035  fprintf(output, "GR\n");
1036 }
1037 
1038 
1039 // computes the mask for the RGB image img of all pixels with color != bg
1040 static uchar *calc_mask(uchar *img, int w, int h, Fl_Color bg)
1041 {
1042  uchar red, green, blue, r, g, b;
1043  uchar bit, byte, *q;
1044  Fl::get_color(bg, red, green, blue);
1045  int W = (w+7)/8; // width of mask
1046  uchar* mask = new uchar[W * h];
1047  q = mask;
1048  while (h-- > 0) { // for each row
1049  bit = 0x80; // byte with last bit set
1050  byte = 0; // next mask byte to compute
1051  for (int j = 0; j < w; j++) { // for each column
1052  r = *img++; // the pixel color components
1053  g = *img++;
1054  b = *img++;
1055  // if pixel doesn't have bg color, put it in mask
1056  if (r != red || g != green || b != blue) byte |= bit;
1057  bit = bit>>1; // shift bit one step to the right
1058  if (bit == 0) { // single set bit has fallen out
1059  *q++ = byte; // enter byte in mask
1060  byte = 0; // reset next mask byte to zero
1061  bit = 0x80; // and this byte
1062  }
1063  }
1064  if (bit != 0x80) *q++ = byte; // enter last columns' byte in mask
1065  }
1066  return mask;
1067 }
1068 
1069 // write to PostScript a bitmap image of a UTF8 string
1070 void Fl_PostScript_Graphics_Driver::transformed_draw_extra(const char* str, int n, double x, double y, int w, bool rtl)
1071 {
1072  // scale for bitmask computation
1073 #if defined(USE_X11) && !USE_XFT
1074  float scale = 1; // don't scale because we can't expect to have scalable fonts
1075 #else
1076  float scale = 2;
1077 #endif
1078  Fl_Fontsize old_size = size();
1079  Fl_Font fontnum = Fl_Graphics_Driver::font();
1080  int w_scaled = (int)(w * (scale + 0.5));
1081  int h = (int)(height() * scale);
1082  // create an offscreen image of the string
1083  Fl_Color text_color = Fl_Graphics_Driver::color();
1084  Fl_Color bg_color = fl_contrast(FL_WHITE, text_color);
1085  Fl_Offscreen off = fl_create_offscreen(w_scaled, (int)(h+3*scale) );
1086  fl_begin_offscreen(off);
1087  fl_color(bg_color);
1088  // color offscreen background with a shade contrasting with the text color
1089  fl_rectf(0, 0, w_scaled, (int)(h+3*scale) );
1090  fl_color(text_color);
1091 #if defined(USE_X11) && !USE_XFT
1092  // force seeing this font as new so it's applied to the offscreen graphics context
1094  fl_font(fontnum, 0);
1095 #endif
1096  fl_font(fontnum, (Fl_Fontsize)(scale * old_size) );
1097  int w2 = (int)fl_width(str, n);
1098  // draw string in offscreen
1099  if (rtl) fl_rtl_draw(str, n, w2, (int)(h * 0.8) );
1100  else fl_draw(str, n, 1, (int)(h * 0.8) );
1101  // read (most of) the offscreen image
1102  uchar *img = fl_read_image(NULL, 1, 1, w2, h, 0);
1103  fl_end_offscreen();
1104  font(fontnum, old_size);
1105  fl_delete_offscreen(off);
1106  // compute the mask of what is not the background
1107  uchar *mask = calc_mask(img, w2, h, bg_color);
1108  delete[] img;
1109  // write the string image to PostScript as a scaled bitmask
1110  scale = w2 / float(w);
1111  clocale_printf("%g %g %g %g %d %d MI\n", x, y - h*0.77/scale, w2/scale, h/scale, w2, h);
1112  uchar *di;
1113  int wmask = (w2+7)/8;
1114  void *rle85 = prepare_rle85();
1115  for (int j = h - 1; j >= 0; j--){
1116  di = mask + j * wmask;
1117  for (int i = 0; i < wmask; i++){
1118  write_rle85(*di, rle85);
1119  di++;
1120  }
1121  }
1122  close_rle85(rle85); fputc('\n', output);
1123  delete[] mask;
1124 }
1125 
1126 static int is_in_table(unsigned utf) {
1127  unsigned i;
1128  static unsigned extra_table_roman[] = { // unicodes/*names*/ of other characters from PostScript standard fonts
1129  0x192/*florin*/, 0x2C6/*circumflex*/, 0x2C7/*caron*/,
1130  0x2D8/*breve*/, 0x2D9/*dotaccent*/, 0x2DA/*ring*/, 0x2DB/*ogonek*/, 0x2DC/*tilde*/, 0x2DD/*hungarumlaut*/,
1131  0x2013/*endash*/, 0x2014/*emdash*/, 0x2018/*quoteleft*/, 0x2019/*quoteright*/,
1132  0x201A/*quotesinglbase*/, 0x201C/*quotedblleft*/, 0x201D/*quotedblright*/, 0x201E/*quotedblbase*/,
1133  0x2020/*dagger*/, 0x2021/*daggerdbl*/, 0x2022/*bullet*/,
1134  0x2026/*ellipsis*/, 0x2030/*perthousand*/, 0x2039/*guilsinglleft*/, 0x203A/*guilsinglright*/,
1135  0x2044/*fraction*/, 0x20AC/*Euro*/, 0x2122/*trademark*/,
1136  0x2202/*partialdiff*/, 0x2206/*Delta*/, 0x2211/*summation*/, 0x221A/*radical*/,
1137  0x221E/*infinity*/, 0x2260/*notequal*/, 0x2264/*lessequal*/,
1138  0x2265/*greaterequal*/,
1139  0x25CA/*lozenge*/, 0xFB01/*fi*/, 0xFB02/*fl*/,
1140  0xF8FF/*apple*/
1141  };
1142  for ( i = 0; i < sizeof(extra_table_roman)/sizeof(int); i++) {
1143  if (extra_table_roman[i] == utf) return i + 0x180;
1144  }
1145  return 0;
1146 }
1147 
1148 // outputs in PostScript a UTF8 string using the same width in points as on display
1149 void Fl_PostScript_Graphics_Driver::transformed_draw(const char* str, int n, double x, double y) {
1150  int len, code;
1151  if (!n || !str || !*str) return;
1152  // compute display width of string
1153  int w = (int)width(str, n);
1154  if (w == 0) return;
1156  transformed_draw_extra(str, n, x, y, w, false);
1157  return;
1158  }
1159  fprintf(output, "%d <~", w);
1160  void *data = prepare85();
1161  // transforms UTF8 encoding to our custom PostScript encoding as follows:
1162  // extract each unicode character
1163  // if unicode <= 0x17F, unicode and PostScript codes are identical
1164  // if unicode is one of the values listed in extra_table_roman above
1165  // its PostScript code is 0x180 + the character's rank in extra_table_roman
1166  // if unicode is something else, draw all string as bitmap image
1167 
1168  const char *last = str + n;
1169  const char *str2 = str;
1170  while (str2 < last) {
1171  // Extract each unicode character of string.
1172  unsigned utf = fl_utf8decode(str2, last, &len);
1173  str2 += len;
1174  if (utf <= 0x17F) { // until Latin Extended-A
1175  ;
1176  }
1177  else if ( (code = is_in_table(utf)) != 0) { // other handled characters
1178  utf = code;
1179  }
1180  else { // unhandled character: draw all string as bitmap image
1181  fprintf(output, "~> pop pop\n"); // close and ignore the opened hex string
1182  transformed_draw_extra(str, n, x, y, w, false);
1183  return;
1184  }
1185  // 2 bytes per character, high-order byte first, encode that to ASCII85
1186  uchar c[2]; c[1] = utf & 0xFF; c[0] = (utf & 0xFF00)>>8; write85(data, c, 2);
1187  }
1188  close85(data);
1189  clocale_printf(" %g %g show_pos_width\n", x, y);
1190 }
1191 
1192 void Fl_PostScript_Graphics_Driver::rtl_draw(const char* str, int n, int x, int y) {
1193  int w = (int)width(str, n);
1194  transformed_draw_extra(str, n, x - w, y, w, true);
1195 }
1196 
1198  clocale_printf("[%g %g %g %g %g %g] CT\n", fl_matrix->a , fl_matrix->b , fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
1199 }
1200 
1202  clocale_printf("[%g %g %g %g %g %g] RCT\n" , fl_matrix->a , fl_matrix->b , fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
1203 }
1204 
1206 
1207 
1209  fprintf(output, "GS\n");
1210  concat();
1211 
1212  fprintf(output, "BP\n");
1213  gap_=1;
1214  shape_=POINTS;
1215 }
1216 
1218  fprintf(output, "GS\n");
1219  concat();
1220  fprintf(output, "BP\n");
1221  gap_=1;
1222  shape_=LINE;
1223 }
1224 
1226  fprintf(output, "GS\n");
1227  concat();
1228  fprintf(output, "BP\n");
1229  gap_=1;
1230  shape_=LOOP;
1231 }
1232 
1234  fprintf(output, "GS\n");
1235  concat();
1236  fprintf(output, "BP\n");
1237  gap_=1;
1238  shape_=POLYGON;
1239 }
1240 
1242  if(shape_==POINTS){
1243  clocale_printf("%g %g MT\n", x , y);
1244  gap_=1;
1245  return;
1246  }
1247  if(gap_){
1248  clocale_printf("%g %g MT\n", x , y);
1249  gap_=0;
1250  }else
1251  clocale_printf("%g %g LT\n", x , y);
1252 }
1253 
1254 void Fl_PostScript_Graphics_Driver::curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3){
1255  if(shape_==NONE) return;
1256  if(gap_)
1257  clocale_printf("%g %g MT\n", x , y);
1258  else
1259  clocale_printf("%g %g LT\n", x , y);
1260  gap_=0;
1261 
1262  clocale_printf("%g %g %g %g %g %g curveto \n", x1 , y1 , x2 , y2 , x3 , y3);
1263 }
1264 
1265 
1266 void Fl_PostScript_Graphics_Driver::circle(double x, double y, double r){
1267  if(shape_==NONE){
1268  fprintf(output, "GS\n");
1269  concat();
1270  // fprintf(output, "BP\n");
1271  clocale_printf("%g %g %g 0 360 arc\n", x , y , r);
1272  reconcat();
1273  // fprintf(output, "ELP\n");
1274  fprintf(output, "GR\n");
1275  }else
1276 
1277  clocale_printf("%g %g %g 0 360 arc\n", x , y , r);
1278 
1279 }
1280 
1281 void Fl_PostScript_Graphics_Driver::arc(double x, double y, double r, double start, double a){
1282  if(shape_==NONE) return;
1283  gap_=0;
1284  if(start>a)
1285  clocale_printf("%g %g %g %g %g arc\n", x , y , r , -start, -a);
1286  else
1287  clocale_printf("%g %g %g %g %g arcn\n", x , y , r , -start, -a);
1288 
1289 }
1290 
1291 void Fl_PostScript_Graphics_Driver::arc(int x, int y, int w, int h, double a1, double a2) {
1292  if (w <= 1 || h <= 1) return;
1293  fprintf(output, "GS\n");
1294  //fprintf(output, "BP\n");
1295  begin_line();
1296  clocale_printf("%g %g TR\n", x + w/2.0 -0.5 , y + h/2.0 - 0.5);
1297  clocale_printf("%g %g SC\n", (w-1)/2.0 , (h-1)/2.0 );
1298  arc(0,0,1,a2,a1);
1299  // fprintf(output, "0 0 1 %g %g arc\n" , -a1 , -a2);
1300  clocale_printf("%g %g SC\n", 2.0/(w-1) , 2.0/(h-1) );
1301  clocale_printf("%g %g TR\n", -x - w/2.0 +0.5 , -y - h/2.0 +0.5);
1302  end_line();
1303 
1304  // fprintf(output, "%g setlinewidth\n", 2/sqrt(w*h));
1305  // fprintf(output, "ELP\n");
1306  // fprintf(output, 2.0/w , 2.0/w , " SC\n";
1307  // fprintf(output, (-x - w/2.0) , (-y - h/2) , " TR\n";
1308  fprintf(output, "GR\n");
1309 }
1310 
1311 void Fl_PostScript_Graphics_Driver::pie(int x, int y, int w, int h, double a1, double a2) {
1312  fprintf(output, "GS\n");
1313  begin_polygon();
1314  clocale_printf("%g %g TR\n", x + w/2.0 -0.5 , y + h/2.0 - 0.5);
1315  clocale_printf("%g %g SC\n", (w-1)/2.0 , (h-1)/2.0 );
1316  vertex(0,0);
1317  arc(0.0,0.0, 1, a2, a1);
1318  end_polygon();
1319  fprintf(output, "GR\n");
1320 }
1321 
1323  gap_=1;
1324  reconcat();
1325  fprintf(output, "ELP\n"); //??
1326  fprintf(output, "GR\n");
1327  shape_=NONE;
1328 }
1329 
1331  gap_=1;
1332  reconcat();
1333  fprintf(output, "ELP\n");
1334  fprintf(output, "GR\n");
1335  shape_=NONE;
1336 }
1338  gap_=1;
1339  reconcat();
1340  fprintf(output, "ECP\n");
1341  fprintf(output, "GR\n");
1342  shape_=NONE;
1343 }
1344 
1346 
1347  gap_=1;
1348  reconcat();
1349  fprintf(output, "EFP\n");
1350  fprintf(output, "GR\n");
1351  shape_=NONE;
1352 }
1353 
1355  reconcat();
1356  if(gap_){
1357  clocale_printf("%g %g MT\n", x , y);
1358  gap_=0;
1359  }else
1360  clocale_printf("%g %g LT\n", x , y);
1361  concat();
1362 }
1363 
1365 
1366 void Fl_PostScript_Graphics_Driver::push_clip(int x, int y, int w, int h) {
1367  Clip * c=new Clip();
1368  clip_box(x,y,w,h,c->x,c->y,c->w,c->h);
1369  c->prev=clip_;
1370  clip_=c;
1371  fprintf(output, "CR\nCS\n");
1372  if(lang_level_<3)
1373  recover();
1374  clocale_printf("%g %g %i %i CL\n", clip_->x-0.5 , clip_->y-0.5 , clip_->w , clip_->h);
1375 
1376 }
1377 
1379  Clip * c = new Clip();
1380  c->prev=clip_;
1381  clip_=c;
1382  clip_->x = clip_->y = clip_->w = clip_->h = -1;
1383  fprintf(output, "CR\nCS\n");
1384  if(lang_level_<3)
1385  recover();
1386 }
1387 
1389  if(!clip_)return;
1390  Clip * c=clip_;
1391  clip_=clip_->prev;
1392  delete c;
1393  fprintf(output, "CR\nCS\n");
1394  if(clip_ && clip_->w >0)
1395  clocale_printf("%g %g %i %i CL\n", clip_->x - 0.5, clip_->y - 0.5, clip_->w , clip_->h);
1396  // uh, -0.5 is to match screen clipping, for floats there should be something beter
1397  if(lang_level_<3)
1398  recover();
1399 }
1400 
1401 int Fl_PostScript_Graphics_Driver::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H){
1402  if(!clip_){
1403  X=x;Y=y;W=w;H=h;
1404  return 1;
1405  }
1406  if(clip_->w < 0){
1407  X=x;Y=y;W=w;H=h;
1408  return 1;
1409  }
1410  int ret=0;
1411  if (x > (X=clip_->x)) {X=x; ret=1;}
1412  if (y > (Y=clip_->y)) {Y=y; ret=1;}
1413  if ((x+w) < (clip_->x+clip_->w)) {
1414  W=x+w-X;
1415 
1416  ret=1;
1417 
1418  }else
1419  W = clip_->x + clip_->w - X;
1420  if(W<0){
1421  W=0;
1422  return 1;
1423  }
1424  if ((y+h) < (clip_->y+clip_->h)) {
1425  H=y+h-Y;
1426  ret=1;
1427  }else
1428  H = clip_->y + clip_->h - Y;
1429  if(H<0){
1430  W=0;
1431  H=0;
1432  return 1;
1433  }
1434  return ret;
1435 }
1436 
1437 int Fl_PostScript_Graphics_Driver::not_clipped(int x, int y, int w, int h){
1438  if(!clip_) return 1;
1439  if(clip_->w < 0) return 1;
1440  int X, Y, W, H;
1441  clip_box(x, y, w, h, X, Y, W, H);
1442  if(W) return 1;
1443  return 0;
1444 }
1445 
1446 void Fl_PostScript_File_Device::margins(int *left, int *top, int *right, int *bottom) // to implement
1447 {
1449  if(left) *left = (int)(ps->left_margin / ps->scale_x + .5);
1450  if(right) *right = (int)(ps->left_margin / ps->scale_x + .5);
1451  if(top) *top = (int)(ps->top_margin / ps->scale_y + .5);
1452  if(bottom) *bottom = (int)(ps->top_margin / ps->scale_y + .5);
1453 }
1454 
1456 //returns 0 iff OK
1457 {
1459  if(w) *w = (int)((ps->pw_ - 2 * ps->left_margin) / ps->scale_x + .5);
1460  if(h) *h = (int)((ps->ph_ - 2 * ps->top_margin) / ps->scale_y + .5);
1461  return 0;
1462 }
1463 
1465 {
1467 }
1468 
1470 {
1471  x_offset = x;
1472  y_offset = y;
1474  ps->clocale_printf("GR GR GS %d %d TR %f %f SC %d %d TR %f rotate GS\n",
1475  ps->left_margin, ps->top_margin, ps->scale_x, ps->scale_y, x, y, ps->angle);
1476 }
1477 
1478 void Fl_PostScript_File_Device::scale (float s_x, float s_y)
1479 {
1480  if (s_y == 0.) s_y = s_x;
1482  ps->scale_x = s_x;
1483  ps->scale_y = s_y;
1484  ps->clocale_printf("GR GR GS %d %d TR %f %f SC %f rotate GS\n",
1485  ps->left_margin, ps->top_margin, ps->scale_x, ps->scale_y, ps->angle);
1486 }
1487 
1489 {
1491  ps->angle = - rot_angle;
1492  ps->clocale_printf("GR GR GS %d %d TR %f %f SC %d %d TR %f rotate GS\n",
1493  ps->left_margin, ps->top_margin, ps->scale_x, ps->scale_y, x_offset, y_offset, ps->angle);
1494 }
1495 
1497 {
1498  fprintf(driver()->output, "GS %d %d translate GS\n", x, y);
1499 }
1500 
1502 {
1503  fprintf(driver()->output, "GR GR\n");
1504 }
1505 
1507 {
1509  ps->page(ps->page_format_);
1510  x_offset = 0;
1511  y_offset = 0;
1512  ps->scale_x = ps->scale_y = 1.;
1513  ps->angle = 0;
1514  fprintf(ps->output, "GR GR GS %d %d translate GS\n", ps->left_margin, ps->top_margin);
1515  return 0;
1516 }
1517 
1519 {
1520  return 0;
1521 }
1522 
1524 // finishes PostScript & closes file
1525 {
1527  if (ps->nPages) { // for eps nPages is 0 so it is fine ....
1528  fprintf(ps->output, "CR\nGR\nGR\nGR\nSP\n restore\n");
1529  if (!ps->pages_){
1530  fprintf(ps->output, "%%%%Trailer\n");
1531  fprintf(ps->output, "%%%%Pages: %i\n" , ps->nPages);
1532  };
1533  } else
1534  fprintf(ps->output, "GR\n restore\n");
1535  fputs("%%EOF",ps->output);
1536  ps->reset();
1537  fflush(ps->output);
1538  if(ferror(ps->output)) {
1539  fl_alert ("Error during PostScript data output.");
1540  }
1541  if (ps->close_cmd_) {
1542  (*ps->close_cmd_)(ps->output);
1543  } else {
1544  fclose(ps->output);
1545  }
1546  while (ps->clip_){
1548  ps->clip_= ps->clip_->prev;
1549  delete c;
1550  }
1552 }
1553 
1554 #endif // FL_DOXYGEN
1555 
1556 #if ! (defined(__APPLE__) || defined(WIN32) )
1557 
1558 int Fl_PostScript_Printer::start_job(int pages, int *firstpage, int *lastpage) {
1559  enum Fl_Paged_Device::Page_Format format;
1560  enum Fl_Paged_Device::Page_Layout layout;
1561 
1562  // first test version for print dialog
1563  if (!print_panel) make_print_panel();
1564  printing_style style = print_load();
1566  print_all->setonly();
1568  print_from->value("1");
1569  { char tmp[10]; snprintf(tmp, sizeof(tmp), "%d", pages); print_to->value(tmp); }
1570  print_panel->show(); // this is modal
1571  while (print_panel->shown()) Fl::wait();
1572 
1573  if (!print_start) // user clicked cancel
1574  return 1;
1575 
1576  // get options
1577 
1578  switch (print_page_size->value()) {
1579  case 0:
1580  format = Fl_Paged_Device::LETTER;
1581  break;
1582  case 2:
1583  format = Fl_Paged_Device::LEGAL;
1584  break;
1585  case 3:
1586  format = Fl_Paged_Device::EXECUTIVE;
1587  break;
1588  case 4:
1589  format = Fl_Paged_Device::A3;
1590  break;
1591  case 5:
1592  format = Fl_Paged_Device::A5;
1593  break;
1594  case 6:
1595  format = Fl_Paged_Device::B5;
1596  break;
1597  case 7:
1598  format = Fl_Paged_Device::ENVELOPE;
1599  break;
1600  case 8:
1601  format = Fl_Paged_Device::DLE;
1602  break;
1603  default:
1604  format = Fl_Paged_Device::A4;
1605  }
1606 
1607  { // page range choice
1608  int from = 1, to = pages;
1609  if (print_pages->value()) {
1610  sscanf(print_from->value(), "%d", &from);
1611  sscanf(print_to->value(), "%d", &to);
1612  }
1613  if (from < 1) from = 1;
1614  if (to > pages) to = pages;
1615  if (to < from) to = from;
1616  if (firstpage) *firstpage = from;
1617  if (lastpage) *lastpage = to;
1618  if (pages > 0) pages = to - from + 1;
1619  }
1620 
1621  if (print_output_mode[0]->value()) layout = Fl_Paged_Device::PORTRAIT;
1622  else if (print_output_mode[1]->value()) layout = Fl_Paged_Device::LANDSCAPE;
1623  else if (print_output_mode[2]->value()) layout = Fl_Paged_Device::PORTRAIT;
1624  else layout = Fl_Paged_Device::LANDSCAPE;
1625 
1626  int print_pipe = print_choice->value(); // 0 = print to file, >0 = printer (pipe)
1627 
1628  const char *media = print_page_size->text(print_page_size->value());
1629  const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
1630  if (!print_pipe) printer = "<File>";
1631 
1632  if (!print_pipe) // fall back to file printing
1633  return Fl_PostScript_File_Device::start_job (pages, format, layout);
1634 
1635  // Print: pipe the output into the lp command...
1636 
1637  char command[1024];
1638  if (style == SystemV) snprintf(command, sizeof(command), "lp -s -d %s -n %d -t '%s' -o media=%s",
1639  printer, print_collate_button->value() ? 1 : (int)(print_copies->value() + 0.5), "FLTK", media);
1640  else snprintf(command, sizeof(command), "lpr -h -P%s -#%d -T FLTK ",
1641  printer, print_collate_button->value() ? 1 : (int)(print_copies->value() + 0.5));
1642 
1644  ps->output = popen(command, "w");
1645  if (!ps->output) {
1646  fl_alert("could not run command: %s\n",command);
1647  return 1;
1648  }
1649  ps->close_command(pclose);
1650  this->set_current();
1651  return ps->start_postscript(pages, format, layout); // start printing
1652 }
1653 
1654 #endif // ! (defined(__APPLE__) || defined(WIN32) )
1655 
1656 
1657 //
1658 // End of "$Id$".
1659 //
prolog
static const char * prolog
Definition: Fl_PostScript.cxx:176
Fl_PostScript_Graphics_Driver::Clip::h
int h
Definition: Fl_PostScript.H:79
Fl_Native_File_Chooser::type
void type(int t)
Definition: Fl_Native_File_Chooser_FLTK.cxx:77
Fl_PostScript_File_Device::printable_rect
int printable_rect(int *w, int *h)
Computes the width and height of the printable area of the page.
Definition: Fl_PostScript.cxx:1455
fl_width
FL_EXPORT double fl_width(const char *txt)
Definition: fl_font.cxx:65
Fl_PostScript_Graphics_Driver::NONE
Definition: Fl_PostScript.H:75
FL_CAP_SQUARE
cap style: end wraps end point
Definition: fl_draw.H:187
print_copies
Fl_Spinner * print_copies
Definition: print_panel.cxx:71
Fl_PostScript_Graphics_Driver::linedash_
char linedash_[256]
Definition: Fl_PostScript.H:96
Fl.H
Fl_PostScript_Graphics_Driver::output
FILE * output
Definition: Fl_PostScript.H:117
Fl_PostScript_Graphics_Driver::POINTS
Definition: Fl_PostScript.H:75
Fl_PostScript_Graphics_Driver::POLYGON
Definition: Fl_PostScript.H:75
Fl_Button::value
int value(int v)
Definition: Fl_Button.cxx:41
Fl_Native_File_Chooser
Definition: Fl_Native_File_Chooser.H:111
Fl_Graphics_Driver::color
Fl_Color color()
see fl_color(void).
Definition: Fl_Device.H:402
Fl_PostScript_Graphics_Driver::end_loop
void end_loop()
see fl_end_loop().
Definition: Fl_PostScript.cxx:1337
Fl_Color
unsigned int Fl_Color
Definition: Enumerations.H:934
dashes_cap
static const double dashes_cap[5][7]
Definition: Fl_PostScript.cxx:874
Fl_PostScript.H
declaration of classes Fl_PostScript_Graphics_Driver, Fl_PostScript_File_Device.
print_load
void print_load()
Definition: print_panel.cxx:510
Fl_PostScript_Graphics_Driver::curve
void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3)
see fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,...
Definition: Fl_PostScript.cxx:1254
Fl_PostScript_Graphics_Driver::top_margin
int top_margin
Definition: Fl_PostScript.H:115
Fl_Button::setonly
void setonly()
Definition: Fl_Button.cxx:59
Fl_PostScript_Graphics_Driver::close85
void close85(void *data)
Definition: ps_image.cxx:92
Fl_PostScript_Graphics_Driver::gap_
int gap_
Definition: Fl_PostScript.H:85
SystemV
Definition: print_panel.h:38
Fl_Menu_::menu
const Fl_Menu_Item * menu() const
Definition: Fl_Menu_.H:110
Fl_PostScript_Graphics_Driver::clip_box
int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
see fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
Definition: Fl_PostScript.cxx:1401
Fl_PostScript_Graphics_Driver::left_margin
int left_margin
Definition: Fl_PostScript.H:114
Fl_Native_File_Chooser::options
void options(int o)
Definition: Fl_Native_File_Chooser_FLTK.cxx:98
Fl_Graphics_Driver::fl_rectf
friend void fl_rectf(int x, int y, int w, int h)
Definition: fl_draw.H:206
Fl_PostScript_Graphics_Driver::width
double width(const char *, int)
see fl_width(const char *str, int n).
Definition: Fl_PostScript.cxx:990
Fl_PostScript_Graphics_Driver::prepare_rle85
void * prepare_rle85()
Definition: ps_image.cxx:123
Fl_PostScript_Graphics_Driver::circle
void circle(double x, double y, double r)
see fl_circle(double x, double y, double r).
Definition: Fl_PostScript.cxx:1266
fl_rgb_color
Fl_Color fl_rgb_color(uchar r, uchar g, uchar b)
Definition: Enumerations.H:997
Fl_PostScript_Graphics_Driver::line
void line(int x1, int y1, int x2, int y2)
see fl_line(int x, int y, int x1, int y1).
Definition: Fl_PostScript.cxx:737
FL_WHITE
const Fl_Color FL_WHITE
Definition: Enumerations.H:971
Fl_PostScript_Graphics_Driver::transformed_vertex
void transformed_vertex(double x, double y)
see fl_transformed_vertex(double xf, double yf).
Definition: Fl_PostScript.cxx:1354
Fl_PostScript_Graphics_Driver::write85
void write85(void *data, const uchar *p, int len)
Definition: ps_image.cxx:72
Fl_PostScript_Graphics_Driver::Clip::w
int w
Definition: Fl_PostScript.H:79
Fl_PostScript_Graphics_Driver::ph_
double ph_
Definition: Fl_PostScript.H:118
Fl_PostScript_Graphics_Driver::shape_
int shape_
Definition: Fl_PostScript.H:91
Fl_PostScript_Graphics_Driver::begin_polygon
void begin_polygon()
see fl_begin_polygon().
Definition: Fl_PostScript.cxx:1233
Fl_PostScript_File_Device::origin
void origin(int *x, int *y)
Computes the page coordinates of the current origin of graphics functions.
Definition: Fl_PostScript.cxx:1464
fl_ask.H
Fl_PostScript_Graphics_Driver::reconcat
void reconcat()
Definition: Fl_PostScript.cxx:1201
Fl_Input_::value
int value(const char *)
Definition: Fl_Input_.cxx:1284
Fl_Native_File_Chooser::title
void title(const char *t)
Definition: Fl_Native_File_Chooser_FLTK.cxx:161
Fl_Graphics_Driver::font
virtual void font(Fl_Font face, Fl_Fontsize fsize)
see fl_font(Fl_Font face, Fl_Fontsize size).
Definition: Fl_Device.H:386
FL_SOLID
line style: ___________
Definition: fl_draw.H:179
Fl_PostScript_File_Device::scale
void scale(float scale_x, float scale_y=0.)
Changes the scaling of page coordinates.
Definition: Fl_PostScript.cxx:1478
Fl_Graphics_Driver::matrix::d
double d
Definition: Fl_Device.H:114
print_start
static int print_start
Definition: print_panel.cxx:60
Fl_Native_File_Chooser::filter
const char * filter() const
Definition: Fl_Native_File_Chooser_FLTK.cxx:173
free
void free()
Fl_Paged_Device::Page_Layout
Page_Layout
Possible page layouts.
Definition: Fl_Paged_Device.H:86
H
static int H
Definition: Fl_Tooltip.cxx:76
Fl_PostScript_File_Device::end_job
void end_job(void)
To be called at the end of a print job.
Definition: Fl_PostScript.cxx:1523
Fl_Graphics_Driver::font
Fl_Font font()
see fl_font(void).
Definition: Fl_Device.H:388
Fl_PostScript_Graphics_Driver::linewidth_
int linewidth_
Definition: Fl_PostScript.H:92
Fl_Graphics_Driver::fl_rtl_draw
friend void fl_rtl_draw(const char *str, int n, int x, int y)
Definition: fl_draw.H:632
Fl_PostScript_Graphics_Driver::Clip
Definition: Fl_PostScript.H:77
Fl_Graphics_Driver::fl_draw
friend void fl_draw(const char *str, int n, int x, int y)
Definition: fl_draw.H:618
Fl_PostScript_Graphics_Driver::yxline
void yxline(int x, int y, int y1)
see fl_yxline(int x, int y, int y1).
Definition: Fl_PostScript.cxx:808
Fl_PostScript_Graphics_Driver::descent
int descent()
see fl_descent().
Definition: Fl_PostScript.cxx:1002
NULL
#define NULL
Definition: forms.H:34
prolog_3
static const char * prolog_3
Definition: Fl_PostScript.cxx:469
Fl_Graphics_Driver::fl_matrix
matrix * fl_matrix
Definition: Fl_Device.H:224
Fl_Paged_Device::B5
Definition: Fl_Paged_Device.H:66
Fl_PostScript_File_Device::class_id
static const char * class_id
Definition: Fl_PostScript.H:233
print_selection
Fl_Round_Button * print_selection
Definition: print_panel.cxx:60
Fl_Graphics_Driver::scale
void scale(double x, double y)
see fl_scale(double x, double y).
Definition: Fl_Device.H:327
Fl_PostScript_Printer::start_job
int start_job(int pages, int *firstpage=NULL, int *lastpage=NULL)
Definition: Fl_PostScript.cxx:1558
Fl_Paged_Device::page_formats
static const page_format page_formats[30]
width, height and name of all elements of the enum Page_Format.
Definition: Fl_Paged_Device.H:105
print_panel
Fl_Double_Window * print_panel
Definition: print_panel.cxx:28
Fl_PostScript_Graphics_Driver::class_id
static const char * class_id
Definition: Fl_PostScript.H:71
prolog_2_pixmap
static const char * prolog_2_pixmap
Definition: Fl_PostScript.cxx:430
Fl_PostScript_Graphics_Driver::close_cmd_
Fl_PostScript_Close_Command * close_cmd_
Definition: Fl_PostScript.H:106
Fl_Widget::do_callback
void do_callback()
Definition: Fl_Widget.H:861
print_panel.cxx
fl_contrast
Fl_Color fl_contrast(Fl_Color fg, Fl_Color bg)
Definition: fl_color.cxx:435
fl_fopen
FILE * fl_fopen(const char *f, const char *mode)
Definition: fl_utf8.cxx:498
Fl_PostScript_Graphics_Driver::scale_x
float scale_x
Definition: Fl_PostScript.H:111
b
long b
Definition: jpegint.h:397
snprintf
#define snprintf
Definition: flstring.h:64
Fl_PostScript_File_Device::margins
void margins(int *left, int *top, int *right, int *bottom)
Computes the dimensions of margins that lie between the printable page area and the full page.
Definition: Fl_PostScript.cxx:1446
Fl_PostScript_Graphics_Driver::transformed_draw_extra
void transformed_draw_extra(const char *str, int n, double x, double y, int w, bool rtl)
Definition: Fl_PostScript.cxx:1070
Fl_Paged_Device::LEGAL
Definition: Fl_Paged_Device.H:77
Fl_PostScript_Graphics_Driver::concat
void concat()
Definition: Fl_PostScript.cxx:1197
Fl_Display_Device::display_device
static Fl_Display_Device * display_device()
Definition: Fl_Device.cxx:83
Fl_PostScript_Graphics_Driver::page_format_
enum Fl_Paged_Device::Page_Format page_format_
Definition: Fl_PostScript.H:128
Fl_PostScript_Graphics_Driver::cb_
unsigned char cb_
Definition: Fl_PostScript.H:95
Fl_PostScript_Graphics_Driver::end_points
void end_points()
see fl_end_points().
Definition: Fl_PostScript.cxx:1322
Fl_PostScript_Graphics_Driver::end_line
void end_line()
see fl_end_line().
Definition: Fl_PostScript.cxx:1330
Fl_PostScript_Graphics_Driver::Clip::y
int y
Definition: Fl_PostScript.H:79
Fl_PostScript_Graphics_Driver::pie
void pie(int x, int y, int w, int h, double a1, double a2)
see fl_pie(int x, int y, int w, int h, double a1, double a2).
Definition: Fl_PostScript.cxx:1311
fl_utf8decode
unsigned fl_utf8decode(const char *p, const char *end, int *len)
Definition: fl_utf.c:137
Fl_Font_Descriptor::font
XUtf8FontStruct * font
Definition: Fl_Font.H:69
Fl_Surface_Device::driver
void driver(Fl_Graphics_Driver *graphics_driver)
Sets the graphics driver of this drawing surface.
Definition: Fl_Device.H:569
Fl_Paged_Device::ENVELOPE
Definition: Fl_Paged_Device.H:80
Fl_Graphics_Driver::matrix::c
double c
Definition: Fl_Device.H:114
Fl_Graphics_Driver::p
XPoint * p
Definition: Fl_Device.H:125
Fl_PostScript_Graphics_Driver::loop
void loop(int x0, int y0, int x1, int y1, int x2, int y2)
see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2).
Definition: Fl_PostScript.cxx:817
Fl_PostScript_Graphics_Driver::Clip::x
int x
Definition: Fl_PostScript.H:79
Fl_PostScript_Graphics_Driver::start_postscript
int start_postscript(int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout)
Definition: Fl_PostScript.cxx:558
Fl_PostScript_Graphics_Driver::transformed_draw
void transformed_draw(const char *s, int n, double x, double y)
Definition: Fl_PostScript.cxx:1149
p
static menustate * p
Definition: Fl_Menu.cxx:606
Fl_PostScript_File_Device::start_page
int start_page(void)
Starts a new printed page.
Definition: Fl_PostScript.cxx:1506
Fl_Menu_Item::user_data
void * user_data() const
Definition: Fl_Menu_Item.H:251
Fl_PostScript_Graphics_Driver::page_policy_
int page_policy_
Definition: Fl_PostScript.H:107
FL_FREE_FONT
const Fl_Font FL_FREE_FONT
first one to allocate
Definition: Enumerations.H:896
print_all
Fl_Round_Button * print_all
Definition: print_panel.cxx:46
Fl_Paged_Device::origin
virtual void origin(int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
Definition: Fl_Paged_Device.cxx:206
Fl::get_color
static unsigned get_color(Fl_Color i)
Definition: fl_color.cxx:359
make_print_panel
Fl_Double_Window * make_print_panel()
Definition: print_panel.cxx:243
Fl_PostScript_File_Device::translate
void translate(int x, int y)
Translates the current graphics origin accounting for the current rotation.
Definition: Fl_PostScript.cxx:1496
Fl_PostScript_Graphics_Driver::LINE
Definition: Fl_PostScript.H:75
print_from
Fl_Int_Input * print_from
Definition: print_panel.cxx:67
command
static unsigned int command(const char *cmd)
Definition: Fl_Help_View.cxx:3018
last
static idle_cb * last
Definition: Fl_add_idle.cxx:34
Fl_PostScript_Graphics_Driver::begin_loop
void begin_loop()
see fl_begin_loop().
Definition: Fl_PostScript.cxx:1225
Fl_PostScript_Graphics_Driver::cg_
unsigned char cg_
Definition: Fl_PostScript.H:95
Fl_Paged_Device::REVERSED
Definition: Fl_Paged_Device.H:89
Fl_Native_File_Chooser::BROWSE_SAVE_FILE
browse to save a file
Definition: Fl_Native_File_Chooser.H:118
fl_draw.H
utility header to pull drawing functions together
Fl_Paged_Device::page_format::height
int height
height in points
Definition: Fl_Paged_Device.H:99
Fl_PostScript_Graphics_Driver::prepare85
void * prepare85()
Definition: ps_image.cxx:43
FL_HELVETICA
const Fl_Font FL_HELVETICA
Helvetica (or Arial) normal (0)
Definition: Enumerations.H:879
Fl_Graphics_Driver::fl_font
friend void fl_font(Fl_Font face, Fl_Fontsize size)
Definition: fl_draw.H:509
Fl_PostScript_File_Device::untranslate
void untranslate(void)
Undoes the effect of a previous translate() call.
Definition: Fl_PostScript.cxx:1501
Fl_Native_File_Chooser::filename
const char * filename() const
Definition: Fl_Native_File_Chooser_FLTK.cxx:126
max
static int max(int i1, int i2)
Definition: Fl_Text_Buffer.cxx:58
ph
static int ph
Definition: fl_overlay.cxx:32
Fl_Spinner::value
double value() const
Definition: Fl_Spinner.H:230
pw
static int pw
Definition: fl_overlay.cxx:32
printing_style
printing_style
Definition: print_panel.h:38
fl_read_image
FL_EXPORT uchar * fl_read_image(uchar *p, int X, int Y, int W, int H, int alpha=0)
Definition: fl_read_image.cxx:152
Fl_PostScript_Graphics_Driver::pw_
double pw_
Definition: Fl_PostScript.H:118
_fontNames
static const char * _fontNames[]
Definition: Fl_PostScript.cxx:941
Fl_Paged_Device::A3
Definition: Fl_Paged_Device.H:54
Fl_Graphics_Driver::matrix::x
double x
Definition: Fl_Device.H:114
Fl_PostScript_Graphics_Driver::polygon
void polygon(int x0, int y0, int x1, int y1, int x2, int y2)
see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2).
Definition: Fl_PostScript.cxx:838
Fl_PostScript_Graphics_Driver::pop_clip
void pop_clip()
see fl_pop_clip().
Definition: Fl_PostScript.cxx:1388
Fl_Choice::value
int value() const
Definition: Fl_Choice.H:95
Fl_Paged_Device::Page_Format
Page_Format
Possible page formats.
Definition: Fl_Paged_Device.H:50
Fl_PostScript_Graphics_Driver::mask
uchar * mask
Definition: Fl_PostScript.H:102
Fl_Fontsize
int Fl_Fontsize
Definition: Enumerations.H:906
Fl_PostScript_Graphics_Driver::bg_b
uchar bg_b
Definition: Fl_PostScript.H:120
Fl_Graphics_Driver::matrix::a
double a
Definition: Fl_Device.H:114
gc
GC gc
Definition: test.c:72
Fl_PostScript_Graphics_Driver::not_clipped
int not_clipped(int x, int y, int w, int h)
see fl_not_clipped(int x, int y, int w, int h).
Definition: Fl_PostScript.cxx:1437
Fl_PostScript_Graphics_Driver::close_command
void close_command(Fl_PostScript_Close_Command *cmd)
Definition: Fl_PostScript.H:133
Fl_Surface_Device::driver
Fl_Graphics_Driver * driver()
Returns the graphics driver of this drawing surface.
Definition: Fl_Device.H:571
Fl_Widget::deactivate
void deactivate()
Definition: Fl_Widget.cxx:253
calc_mask
static uchar * calc_mask(uchar *img, int w, int h, Fl_Color bg)
Definition: Fl_PostScript.cxx:1040
Fl_Printer.H
declaration of classes Fl_Printer, Fl_System_Printer and Fl_PostScript_Printer.
Fl_Paged_Device::page_format::width
int width
width in points
Definition: Fl_Paged_Device.H:97
Fl_PostScript_Graphics_Driver::linestyle_
int linestyle_
Definition: Fl_PostScript.H:93
fl_graphics_driver
FL_EXPORT Fl_Graphics_Driver * fl_graphics_driver
Points to the driver that currently receives all graphics requests.
Definition: Fl_Device.cxx:50
Fl_Paged_Device::LETTER
Definition: Fl_Paged_Device.H:78
Fl_PostScript_Graphics_Driver::line_style
void line_style(int style, int width=0, char *dashes=0)
see fl_line_style(int style, int width, char* dashes).
Definition: Fl_PostScript.cxx:883
Fl_PostScript_File_Device::~Fl_PostScript_File_Device
~Fl_PostScript_File_Device()
The destructor.
Definition: Fl_PostScript.cxx:145
fl_delete_offscreen
void fl_delete_offscreen(Fl_Offscreen gWorld)
Fl_PostScript_Graphics_Driver::rectf
void rectf(int x, int y, int w, int h)
see fl_rectf(int x, int y, int w, int h).
Definition: Fl_PostScript.cxx:733
Fl_Window::shown
int shown()
Definition: Fl_Window.H:485
Fl_Paged_Device::LANDSCAPE
Definition: Fl_Paged_Device.H:88
Fl_PostScript_Graphics_Driver::angle
float angle
Definition: Fl_PostScript.H:113
Fl_Menu_::text
const char * text() const
Definition: Fl_Menu_.H:150
Fl_Surface_Device::set_current
virtual void set_current(void)
Make this surface the current drawing surface. This surface will receive all future graphics requests...
Definition: Fl_Device.cxx:44
Fl_PostScript_Graphics_Driver::rect
void rect(int x, int y, int w, int h)
see fl_rect(int x, int y, int w, int h).
Definition: Fl_PostScript.cxx:718
print_to
Fl_Int_Input * print_to
Definition: print_panel.cxx:69
print_output_mode
Fl_Button * print_output_mode[4]
Definition: print_panel.cxx:215
Fl_Paged_Device::MEDIA
Definition: Fl_Paged_Device.H:81
Fl_PostScript_Graphics_Driver::scale_y
float scale_y
Definition: Fl_PostScript.H:112
dont_close
static int dont_close(FILE *f)
Definition: Fl_PostScript.cxx:108
Fl_Paged_Device::x_offset
int x_offset
horizontal offset to the origin of graphics coordinates
Definition: Fl_Paged_Device.H:110
print_choice
Fl_Choice * print_choice
Definition: print_panel.cxx:32
fl_begin_offscreen
void fl_begin_offscreen(Fl_Offscreen gWorld)
Fl_PostScript_Graphics_Driver::LOOP
Definition: Fl_PostScript.H:75
x
int x
Definition: test.c:73
Fl_Graphics_Driver
A virtual class subclassed for each graphics driver FLTK uses. Typically, FLTK applications do not us...
Definition: Fl_Device.H:110
Fl_PostScript_Graphics_Driver::bg_g
uchar bg_g
Definition: Fl_PostScript.H:120
Fl_Graphics_Driver::matrix::b
double b
Definition: Fl_Device.H:114
Fl_Font
int Fl_Font
Definition: Enumerations.H:877
Fl::wait
static int wait()
Definition: Fl.cxx:666
Fl_PostScript_Graphics_Driver::vertex
void vertex(double x, double y)
see fl_vertex(double x, double y).
Definition: Fl_PostScript.cxx:1241
Fl_PostScript_File_Device::Fl_PostScript_File_Device
Fl_PostScript_File_Device()
The constructor.
Definition: Fl_PostScript.cxx:62
Fl_PostScript_Graphics_Driver::arc
void arc(double x, double y, double r, double start, double a)
see fl_arc(double x, double y, double r, double start, double end).
Definition: Fl_PostScript.cxx:1281
Fl_Graphics_Driver::size
Fl_Fontsize size()
see fl_size().
Definition: Fl_Device.H:390
Fl_PostScript_Graphics_Driver::write_rle85
void write_rle85(uchar b, void *data)
Definition: ps_image.cxx:133
Fl_PostScript_Graphics_Driver::cr_
unsigned char cr_
Definition: Fl_PostScript.H:95
dy
uchar dy
Definition: fl_boxtype.cxx:286
fl_gc
CGContextRef fl_gc
Definition: Fl_win32.cxx:2568
print_page_size
Fl_Choice * print_page_size
Definition: print_panel.cxx:108
y
int y
Definition: test.c:74
Fl_PostScript_File_Device::rotate
void rotate(float angle)
Rotates the graphics operations relatively to paper.
Definition: Fl_PostScript.cxx:1488
Fl_PostScript_Graphics_Driver::push_clip
void push_clip(int x, int y, int w, int h)
see fl_push_clip(int x, int y, int w, int h).
Definition: Fl_PostScript.cxx:1366
fl_end_offscreen
void fl_end_offscreen()
Fl_PostScript_Graphics_Driver::Fl_PostScript_Graphics_Driver
Fl_PostScript_Graphics_Driver()
The constructor.
Definition: Fl_PostScript.cxx:43
f
Fl_Box_Draw_F * f
Definition: fl_boxtype.cxx:285
prolog_2
static const char * prolog_2
Definition: Fl_PostScript.cxx:306
Fl_Offscreen
CGContextRef Fl_Offscreen
Definition: mac.H:45
Fl_PostScript_Graphics_Driver::height
int height()
see fl_height().
Definition: Fl_PostScript.cxx:998
Fl_Native_File_Chooser.H
fl_create_offscreen
Fl_Offscreen fl_create_offscreen(int w, int h)
Fl_PostScript_Graphics_Driver::page_policy
int page_policy()
Definition: Fl_PostScript.H:132
Fl_PostScript_Graphics_Driver::nPages
int nPages
Definition: Fl_PostScript.H:108
Fl_Paged_Device::PORTRAIT
Definition: Fl_Paged_Device.H:87
Y
static int Y
Definition: Fl_Tooltip.cxx:76
Fl_Paged_Device::y_offset
int y_offset
vertical offset to the origin of graphics coordinates
Definition: Fl_Paged_Device.H:112
Fl_Double_Window::show
void show()
Definition: Fl_Double_Window.cxx:79
Fl_PostScript_Graphics_Driver::Clip::prev
Clip * prev
Definition: Fl_PostScript.H:80
Fl_PostScript_Graphics_Driver::text_extents
void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h)
see fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int& h).
Definition: Fl_PostScript.cxx:1006
Fl_Graphics_Driver::fl_color
friend void fl_color(Fl_Color c)
Definition: fl_draw.H:52
Fl_PostScript_File_Device::start_job
int start_job(int pagecount, int *from, int *to)
Definition: Fl_PostScript.cxx:137
Fl_PostScript_Graphics_Driver::begin_points
void begin_points()
see fl_begin_points().
Definition: Fl_PostScript.cxx:1208
Fl_PostScript_Graphics_Driver::push_no_clip
void push_no_clip()
see fl_push_no_clip().
Definition: Fl_PostScript.cxx:1378
Fl_PostScript_Graphics_Driver::rtl_draw
void rtl_draw(const char *s, int n, int x, int y)
see fl_rtl_draw(const char *str, int n, int x, int y).
Definition: Fl_PostScript.cxx:1192
Fl_PostScript_Graphics_Driver
PostScript graphical backend.
Definition: Fl_PostScript.H:61
Fl_Graphics_Driver::n
int n
Definition: Fl_Device.H:124
Fl_PostScript_Graphics_Driver::page
void page(double pw, double ph, int media=0)
Definition: Fl_PostScript.cxx:657
Fl_PostScript_Graphics_Driver::clocale_printf
int clocale_printf(const char *format,...)
Definition: Fl_PostScript.cxx:156
dashes_flat
static const int dashes_flat[5][7]
Definition: Fl_PostScript.cxx:864
Fl_PostScript_Graphics_Driver::ps_filename_
char * ps_filename_
Definition: Fl_PostScript.H:129
Fl_Paged_Device::EXECUTIVE
Definition: Fl_Paged_Device.H:74
Fl_PostScript_File_Device::file_chooser_title
static const char * file_chooser_title
Label of the PostScript file chooser window.
Definition: Fl_PostScript.H:257
Fl_Graphics_Driver::matrix::y
double y
Definition: Fl_Device.H:114
Fl_Paged_Device::A5
Definition: Fl_Paged_Device.H:56
Fl_PostScript_Graphics_Driver::recover
void recover()
Definition: Fl_PostScript.cxx:623
code
Definition: inftrees.h:24
Fl_PostScript_Graphics_Driver::point
void point(int x, int y)
see fl_point(int x, int y).
Definition: Fl_PostScript.cxx:860
Fl_Paged_Device::A4
Definition: Fl_Paged_Device.H:55
start
static int start(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int w, int h, int &cx, int &cy, int &X, int &Y, int &W, int &H)
Definition: Fl_Image.cxx:655
Fl_PostScript_Graphics_Driver::~Fl_PostScript_Graphics_Driver
~Fl_PostScript_Graphics_Driver()
The destructor.
Definition: Fl_PostScript.cxx:55
uchar
unsigned char uchar
Definition: fl_types.h:30
is_in_table
static int is_in_table(unsigned utf)
Definition: Fl_PostScript.cxx:1126
XUtf8FontStruct::font_name_list
char ** font_name_list
Definition: Xutf8.h:32
print_collate_button
Fl_Check_Button * print_collate_button
Definition: print_panel.cxx:85
Fl_PostScript_Graphics_Driver::xyline
void xyline(int x, int y, int x1)
see fl_xyline(int x, int y, int x1).
Definition: Fl_PostScript.cxx:776
name
static const char * name
Definition: Fl_arg.cxx:53
fl_alert
void fl_alert(const char *,...)
Definition: fl_ask.cxx:361
print_pages
Fl_Round_Button * print_pages
Definition: print_panel.cxx:53
Fl_PostScript_Graphics_Driver::clip_
Clip * clip_
Definition: Fl_PostScript.H:82
Fl_PostScript_Graphics_Driver::draw
void draw(const char *s, int nBytes, int x, int y)
see fl_draw(const char *str, int n, int x, int y).
Definition: Fl_PostScript.H:201
Fl_PostScript_Graphics_Driver::lang_level_
int lang_level_
Definition: Fl_PostScript.H:84
Fl_PostScript_Graphics_Driver::begin_line
void begin_line()
see fl_begin_line().
Definition: Fl_PostScript.cxx:1217
Fl_Native_File_Chooser::SAVEAS_CONFIRM
Show native 'Save As' overwrite confirm dialog.
Definition: Fl_Native_File_Chooser.H:123
Fl_PostScript_File_Device::end_page
int end_page(void)
To be called at the end of each page.
Definition: Fl_PostScript.cxx:1518
dx
uchar dx
Definition: fl_boxtype.cxx:286
Fl_Native_File_Chooser::show
int show()
Definition: Fl_Native_File_Chooser_FLTK.cxx:242
Fl_PostScript_Graphics_Driver::pages_
int pages_
Definition: Fl_PostScript.H:86
Fl_PostScript_Graphics_Driver::end_polygon
void end_polygon()
see fl_end_polygon().
Definition: Fl_PostScript.cxx:1345
Fl_Font.H
Fl_PostScript_File_Device::driver
Fl_PostScript_Graphics_Driver * driver()
Returns the PostScript driver of this drawing surface.
Definition: Fl_PostScript.cxx:73
Fl_Graphics_Driver::font_descriptor
Fl_Font_Descriptor * font_descriptor()
Definition: Fl_Device.H:404
Fl_Paged_Device::DLE
Definition: Fl_Paged_Device.H:73
Fl_PostScript_Graphics_Driver::close_rle85
void close_rle85(void *data)
Definition: ps_image.cxx:170
Fl_PostScript_Graphics_Driver::reset
void reset()
Definition: Fl_PostScript.cxx:629
Fl_Font_Descriptor
Definition: Fl_Font.H:41
Fl_PostScript_Graphics_Driver::bg_r
uchar bg_r
Definition: Fl_PostScript.H:120