Initial import from FreeBSD RELENG_4:
[games.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
6    Free Software Foundation, Inc.
7
8    Written by James Clark (jjc@jclark.com)
9
10    Last update: 12 Apr 2002
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, 59 Temple Place - Suite 330, Boston, MA
27    02111-1307, USA.
28 */
29
30 /* Description
31
32    The class `printer' performs the postprocessing.  Each
33    postprocessor only need 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.cc'.
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 struct 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   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 protected:
87   font_pointer_list *font_list;
88
89   // information about named characters
90   int is_char_named;
91   int is_named_set;
92   char named_command;
93   const char *named_char_s;
94   int named_char_n;
95
96 private:
97   font **font_table;
98   int nfonts;
99   font *find_font(const char *);
100   virtual void set_char(int index, font *f, const environment *env,
101                         int w, const char *name) = 0;
102 };
103
104 printer *make_printer();