Back to index

texmacs  1.0.7.15
printer.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : printer.hpp
00004 * DESCRIPTION: Windows under X
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef PRINTER_H
00013 #define PRINTER_H
00014 #include "renderer.hpp"
00015 #include "gui.hpp"
00016 #include "hashmap.hpp"
00017 #include "url.hpp"
00018 
00019 class printer_rep: public renderer_rep {
00020   url      ps_file_name;
00021   int      dpi;
00022   int      nr_pages;
00023   string   page_type;
00024   bool     landscape;
00025   double   paper_w;
00026   double   paper_h;
00027   bool     use_alpha;
00028   string   prologue;
00029   string   body;
00030   int      cur_page;
00031   int      linelen;
00032 
00033   color    fg, bg;
00034   int      ncols;
00035   SI       lw;
00036   int      nwidths;
00037   string   cfn;
00038   int      nfonts;
00039   SI       xpos, ypos;
00040   bool     tex_flag;
00041 
00042   hashmap<string,string> defs;
00043   hashmap<string,string> tex_chars;
00044   hashmap<string,string> tex_width;
00045   hashmap<string,string> tex_fonts;
00046   hashmap<string,array<int> > tex_font_chars;
00047 
00048 public:
00049   printer_rep (url ps_file_name, int dpi, int nr_pages,
00050               string ptype, bool landsc, double paper_w, double paper_h);
00051   ~printer_rep ();
00052   bool is_printer ();
00053   void next_page ();
00054 
00055   /*********************** subroutines for printing **************************/
00056 
00057   void define (string comm, string defn);
00058   void sep ();
00059   void cr ();
00060   void print (string s);
00061   void print (SI x, SI y);
00062   void move_to (SI x, SI y);
00063   string define_alpha (int a);
00064   void select_color (color c);
00065   void select_line_width (SI w);
00066 
00067   /********************* subroutines for drawing text ************************/
00068 
00069   void make_tex_char (string name, QN c, glyph gl);
00070   void select_tex_font (string name);
00071   void generate_tex_fonts ();
00072 
00073   /************************ subroutines hyperlinks ***************************/
00074   void anchor(string label, SI x, SI y);
00075   void href(string label, SI x1, SI y1, SI x2, SI y2);
00076 
00077   /********************** routines from renderer.hpp *************************/
00078 
00079   void  set_clipping (SI x1, SI y1, SI x2, SI y2, bool restore= false);
00080   color get_color ();
00081   color get_background ();
00082   void  set_color (color c);
00083   void  set_background (color c);
00084   void  draw (int char_code, font_glyphs fn, SI x, SI y);
00085   void  set_line_style (SI w, int type=0, bool round=true);
00086   void  line (SI x1, SI y1, SI x2, SI y2);
00087   void  lines (array<SI> x, array<SI> y);
00088   void  clear (SI x1, SI y1, SI x2, SI y2);
00089   void  fill (SI x1, SI y1, SI x2, SI y2);
00090   void  arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00091   void  fill_arc (SI x1, SI y1, SI x2, SI y2, int alpha, int delta);
00092   void  polygon (array<SI> x, array<SI> y, bool convex=true);
00093   void  xpm (url file_name, SI x, SI y);
00094   void  image (url u, SI w, SI h, SI x, SI y,
00095               double cx1, double cy1, double cx2, double cy2,
00096                int alpha);
00097 
00098   void fetch (SI x1, SI y1, SI x2, SI y2, renderer ren, SI x, SI y);
00099   void new_shadow (renderer& ren);
00100   void delete_shadow (renderer& ren);
00101   void get_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00102   void put_shadow (renderer ren, SI x1, SI y1, SI x2, SI y2);
00103   void apply_shadow (SI x1, SI y1, SI x2, SI y2);
00104 };
00105 
00106 renderer printer (url ps_file_name, int dpi, int nr_pages= 1,
00107                 string page_type= "a4", bool landscape= false,
00108                 double paper_w= 21.0, double paper_h= 29.7);
00109 
00110 #endif // defined PRINTER_H