Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / output / output.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000 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 #if !output_h
18 #define output_h 1
19
20 #include <config.h>
21
22 #include <libpspp/str.h>
23
24
25 /* Line styles.  */
26 enum outp_line_style
27   {
28     OUTP_L_NONE,                /* No line. */
29     OUTP_L_SINGLE,              /* Single line. */
30     OUTP_L_DOUBLE,              /* Double line. */
31     OUTP_L_COUNT
32   };
33
34 /* Text justification. */
35 enum outp_justification
36   {
37     OUTP_RIGHT,                 /* Right justification. */
38     OUTP_LEFT,                  /* Left justification. */
39     OUTP_CENTER,                /* Center justification. */
40   };
41
42 enum outp_font
43   {
44     OUTP_FIXED,                 /* Fixed-width font. */
45     OUTP_PROPORTIONAL,          /* Proportional font. */
46     OUTP_EMPHASIS,              /* Proportional font used for emphasis. */
47     OUTP_FONT_CNT               /* Number of fonts. */
48   };
49
50 /* Describes text output. */
51 struct outp_text
52   {
53     enum outp_font font;
54     enum outp_justification justification;
55     struct substring string;
56     int h, v;                   /* Horizontal, vertical size. */
57     int x, y;                   /* Position. */
58   };
59
60 struct som_entity;
61 struct outp_driver;
62 struct chart;
63
64 /* Defines a class of output driver. */
65 struct outp_class
66   {
67     const char *name;           /* Name of this driver class. */
68     int special;                /* Boolean value. */
69
70     bool (*open_driver) (struct outp_driver *, struct substring options);
71     bool (*close_driver) (struct outp_driver *);
72
73     void (*open_page) (struct outp_driver *);
74     void (*close_page) (struct outp_driver *);
75
76     /* special != 0 only. */
77     void (*submit) (struct outp_driver *, struct som_entity *);
78
79     /* special == 0 only.  */
80     void (*line) (struct outp_driver *, int x0, int y0, int x1, int y1,
81                   enum outp_line_style top, enum outp_line_style left,
82                   enum outp_line_style bottom, enum outp_line_style right);
83     void (*text_metrics) (struct outp_driver *, const struct outp_text *,
84                           int *width, int *height);
85     void (*text_draw) (struct outp_driver *, const struct outp_text *);
86     void (*initialise_chart)(struct outp_driver *, struct chart *);
87     void (*finalise_chart)(struct outp_driver *, struct chart *);
88   };
89
90 /* Device types. */
91 enum
92   {
93     OUTP_DEV_NONE = 0,          /* None of the below. */
94     OUTP_DEV_LISTING = 001,     /* Listing device. */
95     OUTP_DEV_SCREEN = 002,      /* Screen device. */
96     OUTP_DEV_PRINTER = 004,     /* Printer device. */
97   };
98
99 /* Defines the configuration of an output driver. */
100 struct outp_driver
101   {
102     struct outp_driver *next, *prev; /* List of drivers. */
103     const struct outp_class *class;     /* Driver class. */
104     char *name;                 /* Name of this driver. */
105     bool page_open;             /* 1=page is open, 0=page is closed. */
106     int device;                 /* Zero or more of OUTP_DEV_*. */
107     int cp_x, cp_y;             /* Current position. */
108
109     int width, length;          /* Page size. */
110     int font_height;            /* Default font character height. */
111     int prop_em_width;          /* Proportional font em width. */
112     int fixed_width;            /* Fixed-pitch font character width. */
113     int horiz_line_width[OUTP_L_COUNT]; /* Width of horizontal lines. */
114     int vert_line_width[OUTP_L_COUNT];  /* Width of vertical lines. */
115
116     void *ext;                  /* Private extension record. */
117     void *prc;                  /* Per-procedure 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_read_devices (void);
135 void outp_done (void);
136
137 void outp_configure_clear (void);
138 void outp_configure_add (char *);
139 void outp_configure_macro (char *);
140
141 void outp_list_classes (void);
142
143 void outp_enable_device (int enable, int device);
144 struct outp_driver *outp_drivers (struct outp_driver *);
145
146 bool outp_parse_options (struct substring options,
147                          bool (*) (struct outp_driver *, const char *key,
148                                    const struct string *value),
149                          struct outp_driver *);
150 int outp_match_keyword (const char *, const struct outp_option *, int *);
151
152 int outp_evaluate_dimension (char *, char **);
153 bool outp_get_paper_size (char *, int *h, int *v);
154
155 void outp_open_page (struct outp_driver *);
156 void outp_close_page (struct outp_driver *);
157 void outp_eject_page (struct outp_driver *);
158
159 int outp_string_width (struct outp_driver *, const char *, enum outp_font);
160
161 /* Imported from som-frnt.c. */
162 void som_destroy_driver (struct outp_driver *);
163
164 #endif /* output.h */