]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/groff/src/include/printer.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / groff / src / include / printer.h
1 // -*- C++ -*-
2
3 // <groff_src_dir>/src/include/printer.h
4
5 /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004
6    Free Software Foundation, Inc.
7
8    Written by James Clark (jjc@jclark.com)
9
10    Last update: 15 Dec 2004
11
12    This file is part of groff.
13
14    groff is free software; you can redistribute it and/or modify it
15    under the terms of the GNU General Public License as published by
16    the Free Software Foundation; either version 2, or (at your option)
17    any later version.
18
19    groff is distributed in the hope that it will be useful, but
20    WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22    General Public License for more details.
23
24    You should have received a copy of the GNU General Public License
25    along with groff; see the file COPYING.  If not, write to the Free
26    Software Foundation, 51 Franklin St - Fifth Floor, Boston, MA
27    02110-1301, USA.
28 */
29
30 /* Description
31
32    The class `printer' performs the postprocessing.  Each
33    postprocessor only needs to implement a derived class of `printer' and
34    a suitable function `make_printer' for the device-dependent tasks.
35    Then the methods of class `printer' are called automatically by
36    `do_file()' in `input.cpp'.
37 */
38
39 #include "color.h"
40
41 struct environment {
42   int fontno;
43   int size;
44   int hpos;
45   int vpos;
46   int height;
47   int slant;
48   color *col;
49   color *fill;
50 };
51
52 class font;
53
54 struct font_pointer_list {
55   font *p;
56   font_pointer_list *next;
57
58   font_pointer_list(font *, font_pointer_list *);
59 };
60
61 class printer {
62 public:
63   printer();
64   virtual ~printer();
65   void load_font(int i, const char *name);
66   void set_ascii_char(unsigned char c, const environment *env,
67                       int *widthp = 0);
68   void set_special_char(const char *nm, const environment *env,
69                         int *widthp = 0);
70   virtual void set_numbered_char(int n, const environment *env,
71                                  int *widthp = 0);
72   int set_char_and_width(const char *nm, const environment *env,
73                          int *widthp, font **f);
74   font *get_font_from_index(int fontno);
75   virtual void draw(int code, int *p, int np, const environment *env);
76   // perform change of line color (text, outline) in the print-out 
77   virtual void change_color(const environment * const env);
78   // perform change of fill color in the print-out 
79   virtual void change_fill_color(const environment * const env);
80   virtual void begin_page(int) = 0;
81   virtual void end_page(int page_length) = 0;
82   virtual font *make_font(const char *nm);
83   virtual void end_of_line();
84   virtual void special(char *arg, const environment *env,
85                        char type = 'p');
86   virtual void devtag(char *arg, const environment *env,
87                       char type = 'p');
88
89 protected:
90   font_pointer_list *font_list;
91   font **font_table;
92   int nfonts;
93
94   // information about named characters
95   int is_char_named;
96   int is_named_set;
97   char named_command;
98   const char *named_char_s;
99   int named_char_n;
100
101 private:
102   font *find_font(const char *);
103   virtual void set_char(int index, font *f, const environment *env,
104                         int w, const char *name) = 0;
105 };
106
107 printer *make_printer();