Added new files resulting from directory restructuring.
[pspp-builds.git] / src / output / output.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #if !output_h
21 #define output_h 1
22
23 #include "str.h"
24 #include "config.h"
25
26 /* A rectangle. */
27 struct rect
28   {
29     int x1, y1;                 /* Upper left. */
30     int x2, y2;                 /* Lower right, not part of the rectangle. */
31   };
32
33 /* Color descriptor. */
34 struct color
35   {
36     int flags;                  /* 0=normal, 1=transparent (ignore r,g,b). */
37     int r;                      /* Red component, 0-65535. */
38     int g;                      /* Green component, 0-65535. */
39     int b;                      /* Blue component, 0-65535. */
40   };
41
42 /* Mount positions for the four basic fonts.  Do not change the values. */
43 enum
44   {
45     OUTP_F_R,                   /* Roman font. */
46     OUTP_F_I,                   /* Italic font. */
47     OUTP_F_B,                   /* Bold font. */
48     OUTP_F_BI                   /* Bold-italic font. */
49   };
50
51 /* Line styles.  These must match:
52    som.h:SLIN_*
53    ascii.c:ascii_line_*() 
54    postscript.c:ps_line_*() */
55 enum
56   {
57     OUTP_L_NONE = 0,            /* No line. */
58     OUTP_L_SINGLE = 1,          /* Single line. */
59     OUTP_L_DOUBLE = 2,          /* Double line. */
60     OUTP_L_SPECIAL = 3,         /* Special line of driver-defined style. */
61
62     OUTP_L_COUNT                /* Number of line styles. */
63   };
64
65 /* Contains a line style for each part of an intersection. */
66 struct outp_styles
67   {
68     int l;                      /* left */
69     int t;                      /* top */
70     int r;                      /* right */
71     int b;                      /* bottom */
72   };
73
74 /* Text display options. */
75 enum
76   {
77     OUTP_T_NONE = 0,
78
79     /* Must match tab.h:TAB_*. */
80     OUTP_T_JUST_MASK = 00003,   /* Justification mask. */
81     OUTP_T_JUST_RIGHT = 00000,  /* Right justification. */
82     OUTP_T_JUST_LEFT = 00001,   /* Left justification. */
83     OUTP_T_JUST_CENTER = 00002, /* Center justification. */
84
85     OUTP_T_HORZ = 00010,        /* Horizontal size is specified. */
86     OUTP_T_VERT = 00020,        /* (Max) vertical size is specified. */
87
88     OUTP_T_0 = 00140,           /* Normal orientation. */
89     OUTP_T_CC90 = 00040,        /* 90 degrees counterclockwise. */
90     OUTP_T_CC180 = 00100,       /* 180 degrees counterclockwise. */
91     OUTP_T_CC270 = 00140,       /* 270 degrees counterclockwise. */
92     OUTP_T_C90 = 00140,         /* 90 degrees clockwise. */
93     OUTP_T_C180 = 00100,        /* 180 degrees clockwise. */
94     OUTP_T_C270 = 00040,        /* 270 degrees clockwise. */
95
96     /* Internal use by drivers only. */
97     OUTP_T_INTERNAL_DRAW = 01000        /* 1=Draw the text, 0=Metrics only. */
98   };
99
100 /* Describes text output. */
101 struct outp_text
102   {
103     /* Public. */
104     int options;                /* What is specified. */
105     struct fixed_string s;      /* String. */
106     int h, v;                   /* Horizontal, vertical size. */
107     int x, y;                   /* Position. */
108
109     /* Internal use only. */
110     int w, l;                   /* Width, length. */
111   };
112
113 struct som_entity;
114 struct outp_driver;
115 struct chart;
116
117 /* Defines a class of output driver. */
118 struct outp_class
119   {
120     /* Basic class information. */
121     const char *name;           /* Name of this driver class. */
122     int magic;                  /* Driver-specific constant. */
123     int special;                /* Boolean value. */
124
125     /* Static member functions. */
126     int (*open_global) (struct outp_class *);
127     int (*close_global) (struct outp_class *);
128     int *(*font_sizes) (struct outp_class *, int *n_valid_sizes);
129
130     /* Virtual member functions. */
131     int (*preopen_driver) (struct outp_driver *);
132     void (*option) (struct outp_driver *, const char *key,
133                     const struct string *value);
134     int (*postopen_driver) (struct outp_driver *);
135     int (*close_driver) (struct outp_driver *);
136
137     int (*open_page) (struct outp_driver *);
138     int (*close_page) (struct outp_driver *);
139
140     /* special != 0: Used to submit entities for output. */
141     void (*submit) (struct outp_driver *, struct som_entity *);
142     
143     /* special != 0: Methods below need not be defined. */
144     
145     /* Line methods. */
146     void (*line_horz) (struct outp_driver *, const struct rect *,
147                        const struct color *, int style);
148     void (*line_vert) (struct outp_driver *, const struct rect *,
149                        const struct color *, int style);
150     void (*line_intersection) (struct outp_driver *, const struct rect *,
151                                const struct color *,
152                                const struct outp_styles *style);
153
154     /* Drawing methods. */
155     void (*box) (struct outp_driver *, const struct rect *,
156                  const struct color *bord, const struct color *fill);
157     void (*polyline_begin) (struct outp_driver *, const struct color *);
158     void (*polyline_point) (struct outp_driver *, int, int);
159     void (*polyline_end) (struct outp_driver *);
160
161     /* Text methods. */
162     void (*text_set_font_by_name) (struct outp_driver *, const char *s);
163     void (*text_set_font_by_position) (struct outp_driver *, int);
164     void (*text_set_font_family) (struct outp_driver *, const char *s);
165     const char *(*text_get_font_name) (struct outp_driver *);
166     const char *(*text_get_font_family) (struct outp_driver *);
167     int (*text_set_size) (struct outp_driver *, int);
168     int (*text_get_size) (struct outp_driver *, int *em_width);
169     void (*text_metrics) (struct outp_driver *, struct outp_text *);
170     void (*text_draw) (struct outp_driver *, struct outp_text *);
171
172     void (*initialise_chart)(struct outp_driver *, struct chart *);
173     void (*finalise_chart)(struct outp_driver *, struct chart *);
174
175   };
176
177 /* Device types. */
178 enum
179   {
180     OUTP_DEV_NONE = 0,          /* None of the below. */
181     OUTP_DEV_LISTING = 001,     /* Listing device. */
182     OUTP_DEV_SCREEN = 002,      /* Screen device. */
183     OUTP_DEV_PRINTER = 004,     /* Printer device. */
184     OUTP_DEV_DISABLED = 010     /* Broken device. */
185   };
186
187 /* Defines the configuration of an output driver. */
188 struct outp_driver
189   {
190     struct outp_class *class;           /* Driver class. */
191     char *name;                 /* Name of this driver. */
192     int driver_open;            /* 1=driver is open, 0=driver is closed. */
193     int page_open;              /* 1=page is open, 0=page is closed. */
194
195     struct outp_driver *next, *prev;    /* Next, previous output driver in list. */
196
197     int device;                 /* Zero or more of OUTP_DEV_*. */
198     int res, horiz, vert;       /* Device resolution. */
199     int width, length;          /* Page size. */
200
201     int cp_x, cp_y;             /* Current position. */
202     int font_height;            /* Default font character height. */
203     int prop_em_width;          /* Proportional font em width. */
204     int fixed_width;            /* Fixed-pitch font character width. */
205     int horiz_line_width[OUTP_L_COUNT]; /* Width of horizontal lines. */
206     int vert_line_width[OUTP_L_COUNT];  /* Width of vertical lines. */
207     int horiz_line_spacing[1 << OUTP_L_COUNT];
208     int vert_line_spacing[1 << OUTP_L_COUNT];
209
210     void *ext;                  /* Private extension record. */
211     void *prc;                  /* Per-procedure extension record. */
212   };
213
214 /* Option structure for the keyword recognizer. */
215 struct outp_option
216   {
217     const char *keyword;        /* Keyword name. */
218     int cat;                    /* Category. */
219     int subcat;                 /* Subcategory. */
220   };
221
222 /* Information structure for the keyword recognizer. */
223 struct outp_option_info
224   {
225     char *initial;                      /* Initial characters. */
226     struct outp_option **options;       /* Search starting points. */
227   };
228
229 /* A list of driver classes. */
230 struct outp_driver_class_list
231   {
232     int ref_count;
233     struct outp_class *class;
234     struct outp_driver_class_list *next;
235   };
236
237 /* List of configured output drivers. */
238 extern struct outp_driver *outp_driver_list;
239
240 /* Title, subtitle. */
241 extern char *outp_title;
242 extern char *outp_subtitle;
243
244 void outp_init (void);
245 void outp_read_devices (void);
246 void outp_done (void);
247
248 void outp_configure_clear (void);
249 void outp_configure_add (char *);
250 void outp_configure_macro (char *);
251
252 void outp_list_classes (void);
253
254 void outp_enable_device (int enable, int device);
255 struct outp_driver *outp_drivers (struct outp_driver *);
256
257 int outp_match_keyword (const char *, struct outp_option *,
258                         struct outp_option_info *, int *);
259
260 int outp_evaluate_dimension (char *, char **);
261 int outp_get_paper_size (char *, int *h, int *v);
262
263 int outp_eject_page (struct outp_driver *);
264
265 int outp_string_width (struct outp_driver *, const char *);
266
267 /* Imported from som-frnt.c. */
268 void som_destroy_driver (struct outp_driver *);
269
270 #endif /* output.h */