output: Remove PostScript driver.
[pspp-builds.git] / src / output / output.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 2007, 2009 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef OUTPUT_OUTPUT_H
18 #define OUTPUT_OUTPUT_H 1
19
20 #include <libpspp/ll.h>
21 #include <libpspp/str.h>
22
23 /* Line styles.  */
24 enum outp_line_style
25   {
26     OUTP_L_NONE,                /* No line. */
27     OUTP_L_SINGLE,              /* Single line. */
28     OUTP_L_DOUBLE,              /* Double line. */
29     OUTP_L_COUNT
30   };
31
32 /* Text justification. */
33 enum outp_justification
34   {
35     OUTP_RIGHT,                 /* Right justification. */
36     OUTP_LEFT,                  /* Left justification. */
37     OUTP_CENTER,                /* Center justification. */
38   };
39
40 enum outp_font
41   {
42     OUTP_FIXED,                 /* Fixed-width font. */
43     OUTP_PROPORTIONAL,          /* Proportional font. */
44     OUTP_EMPHASIS,              /* Proportional font used for emphasis. */
45     OUTP_FONT_CNT               /* Number of fonts. */
46   };
47
48 /* Describes text output. */
49 struct outp_text
50   {
51     enum outp_font font;
52     enum outp_justification justification;
53     struct substring string;
54     int h, v;                   /* Horizontal, vertical size. */
55     int x, y;                   /* Position. */
56   };
57
58 struct som_entity;
59 struct outp_driver;
60 struct chart;
61
62 /* Defines a class of output driver. */
63 struct outp_class
64   {
65     const char *name;           /* Name of this driver class. */
66     int special;                /* Boolean value. */
67
68     bool (*open_driver) (const char *name, int types,
69                          struct substring options);
70     bool (*close_driver) (struct outp_driver *);
71
72     void (*open_page) (struct outp_driver *);
73     void (*close_page) (struct outp_driver *);
74
75     void (*flush) (struct outp_driver *);
76
77     void (*output_chart) (struct outp_driver *, const struct chart *);
78
79     /* special != 0 only. */
80     void (*submit) (struct outp_driver *, struct som_entity *);
81
82     /* special == 0 only.  */
83     void (*line) (struct outp_driver *, int x0, int y0, int x1, int y1,
84                   enum outp_line_style top, enum outp_line_style left,
85                   enum outp_line_style bottom, enum outp_line_style right);
86     void (*text_metrics) (struct outp_driver *, const struct outp_text *,
87                           int *width, int *height);
88     void (*text_draw) (struct outp_driver *, const struct outp_text *);
89   };
90
91 /* Device types. */
92 enum
93   {
94     OUTP_DEV_NONE = 0,          /* None of the below. */
95     OUTP_DEV_LISTING = 001,     /* Listing device. */
96     OUTP_DEV_SCREEN = 002,      /* Screen device. */
97     OUTP_DEV_PRINTER = 004,     /* Printer device. */
98   };
99
100 /* Defines the configuration of an output driver. */
101 struct outp_driver
102   {
103     struct ll node;             /* Node in list of drivers. */
104     const struct outp_class *class;     /* Driver class. */
105     char *name;                 /* Name of this driver. */
106     bool page_open;             /* 1=page is open, 0=page is closed. */
107     int device;                 /* Zero or more of OUTP_DEV_*. */
108     int cp_x, cp_y;             /* Current position. */
109
110     int width, length;          /* Page size. */
111     int font_height;            /* Default font character height. */
112     int prop_em_width;          /* Proportional font em width. */
113     int fixed_width;            /* Fixed-pitch font character width. */
114     int horiz_line_width[OUTP_L_COUNT]; /* Width of horizontal lines. */
115     int vert_line_width[OUTP_L_COUNT];  /* Width of vertical lines. */
116
117     void *ext;                  /* Private extension record. */
118   };
119
120 /* Option structure for the keyword recognizer. */
121 struct outp_option
122   {
123     const char *keyword;        /* Keyword name. */
124     int cat;                    /* Category. */
125     int subcat;                 /* Subcategory. */
126   };
127
128
129 /* Title, subtitle. */
130 extern char *outp_title;
131 extern char *outp_subtitle;
132
133 void outp_init (void);
134 void outp_done (void);
135 void outp_read_devices (void);
136 void outp_configure_driver_line (struct substring);
137
138 struct outp_driver *outp_allocate_driver (const struct outp_class *class,
139                                           const char *name, int types);
140 void outp_free_driver (struct outp_driver *);
141 void outp_register_driver (struct outp_driver *);
142 void outp_unregister_driver (struct outp_driver *);
143
144 void outp_configure_clear (void);
145 void outp_configure_add (char *);
146 void outp_configure_macro (char *);
147
148 void outp_list_classes (void);
149
150 void outp_enable_device (bool enable, int device);
151 struct outp_driver *outp_drivers (struct outp_driver *);
152
153 bool outp_parse_options (const char *driver_name, struct substring options,
154                          bool (*callback) (void *aux, const char *key,
155                                            const struct string *value),
156                          void *aux);
157 int outp_match_keyword (const char *, const struct outp_option *, int *);
158
159 int outp_evaluate_dimension (const char *);
160 bool outp_get_paper_size (const char *, int *h, int *v);
161
162 void outp_open_page (struct outp_driver *);
163 void outp_close_page (struct outp_driver *);
164 void outp_eject_page (struct outp_driver *);
165 void outp_flush (struct outp_driver *);
166
167 int outp_string_width (struct outp_driver *, const char *, enum outp_font);
168
169 /* Imported from som-frnt.c. */
170 void som_destroy_driver (struct outp_driver *);
171
172 /* Common drivers. */
173 extern const struct outp_class ascii_class;
174 #ifdef HAVE_CAIRO
175 extern const struct outp_class cairo_class;
176 #endif
177 extern const struct outp_class odt_class;
178
179 #endif /* output/output.h */