1 2 /****************************************************************************** 3 * MODULE : printer.hpp 4 * DESCRIPTION: Windows under X 5 * COPYRIGHT : (C) 1999 Joris van der Hoeven 6 ******************************************************************************* 7 * This software falls under the GNU general public license version 3 or later. 8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE 9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>. 10 ******************************************************************************/ 11 12 #ifndef PRINTER_H 13 #define PRINTER_H 14 #include "renderer.hpp" 15 #include "gui.hpp" 16 #include "hashmap.hpp" 17 #include "url.hpp" 18 19 class printer_rep: public renderer_rep { 20 url ps_file_name; 21 int dpi; 22 int nr_pages; 23 string page_type; 24 bool landscape; 25 double paper_w; 26 double paper_h; 27 int psw; 28 int psh; 29 bool use_alpha; 30 string prologue; 31 string body; 32 int cur_page; 33 int linelen; 34 35 color fg, bg; 36 int opacity; 37 pencil pen; 38 brush bgb; 39 int ncols; 40 SI lw; 41 int nwidths; 42 string cfn; 43 int nfonts; 44 SI xpos, ypos; 45 bool tex_flag; 46 tree toc; 47 48 hashmap<string,string> defs; 49 hashmap<string,string> tex_chars; 50 hashmap<string,string> tex_width; 51 hashmap<string,string> tex_fonts; 52 hashmap<string,array<int> > tex_font_chars; 53 hashmap<string,string> metadata; 54 55 public: 56 printer_rep (url ps_file_name, int dpi, int nr_pages, 57 string ptype, bool landsc, double paper_w, double paper_h); 58 ~printer_rep (); 59 bool is_printer (); 60 void next_page (); 61 62 /*********************** subroutines for printing **************************/ 63 64 void define (string comm, string defn); 65 void sep (); 66 void cr (); 67 void print (string s); 68 void print (SI x, SI y); 69 void move_to (SI x, SI y); 70 string define_alpha (int a); 71 void select_color (color c); 72 void select_line_width (SI w); 73 74 /********************* subroutines for drawing text ************************/ 75 76 void make_tex_char (string name, QN c, glyph gl); 77 void select_tex_font (string name); 78 void generate_tex_fonts (); 79 80 /************************ subroutines hyperlinks ***************************/ 81 82 void anchor (string label, SI x1, SI y1, SI x2, SI y2); 83 void href (string label, SI x1, SI y1, SI x2, SI y2); 84 void toc_entry (string kind, string title, SI x, SI y); 85 void generate_toc_item (tree t); 86 void generate_toc (); 87 void set_metadata (string kind, string val); 88 void generate_metadata (); 89 90 /********************** routines from renderer.hpp *************************/ 91 92 void set_transformation (frame fr); 93 void reset_transformation (); 94 95 void set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore= false); 96 pencil get_pencil (); 97 brush get_background (); 98 void set_pencil (pencil p); 99 void set_background (brush b); 100 void draw (int char_code, font_glyphs fn, SI x, SI y); 101 void line (SI x1, SI y1, SI x2, SI y2); 102 void lines (array<SI> x, array<SI> y); 103 void clear (SI x1, SI y1, SI x2, SI y2); 104 void fill (SI x1, SI y1, SI x2, SI y2); 105 void arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta); 106 void fill_arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta); 107 void polygon (array<SI> x, array<SI> y, bool convex=true); 108 109 void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y); 110 void new_shadow (renderer& ren); 111 void delete_shadow (renderer& ren); 112 void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2); 113 void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2); 114 void apply_shadow (SI x1, SI y1, SI x2, SI y2); 115 116 renderer shadow (picture& pic, SI x1, SI y1, SI x2, SI y2); 117 void draw_picture (picture p, SI x, SI y, int alpha); 118 void draw_scalable (scalable im, SI x, SI y, int alpha); 119 void image (string name, string eps, SI x1, SI y1, SI x2, SI y2, 120 SI w, SI h, SI x, SI y, int alpha); 121 }; 122 123 renderer printer (url ps_file_name, int dpi, int nr_pages= 1, 124 string page_type= "a4", bool landscape= false, 125 double paper_w= 21.0, double paper_h= 29.7); 126 127 #endif // defined PRINTER_H 128