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