Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / output / manager.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 !som_h
18 #define som_h 1
19
20 /* Structured Output Manager.
21
22    som considers the output stream to be a series of tables.  Each
23    table is made up of a rectangular grid of cells.  Cells can be
24    joined to form larger cells.  Rows and columns can be separated by
25    rules of various types.  Tables too large to fit on a single page
26    will be divided into sections.  Rows and columns can be designated
27    as headers, which causes them to be repeated in each section.
28
29    Every table is an instance of a particular table class.  A table
30    class is responsible for keeping track of cell data, for handling
31    requests from the som, and finally for rendering cell data to the
32    output drivers.  Tables may implement these operations in any way
33    desired, and in fact almost every operation performed by som may be
34    overridden in a table class.  */
35
36 #include <stdbool.h>
37
38 enum som_type
39   {
40     SOM_TABLE,
41     SOM_CHART
42   } ;
43
44 /* Entity (Table or Chart) . */
45 struct som_entity
46   {
47     const struct som_table_class *class;        /* Table class. */
48     enum som_type type;                 /* Table or Chart */
49     void *ext;                          /* Owned by */
50   };
51
52 /* Group styles. */
53 enum
54   {
55     SOM_COL_NONE,                       /* No columns. */
56     SOM_COL_DOWN                        /* Columns down first. */
57   };
58
59 /* Cumulation types. */
60 enum
61   {
62     SOM_ROWS, SOM_ROW = SOM_ROWS,       /* Rows. */
63     SOM_COLUMNS, SOM_COLUMN = SOM_COLUMNS       /* Columns. */
64   };
65
66 /* Flags. */
67 enum
68   {
69     SOMF_NONE = 0,
70     SOMF_NO_SPACING = 01,       /* No spacing before the table. */
71     SOMF_NO_TITLE = 02          /* No title. */
72   };
73
74 /* Table class. */
75 struct outp_driver;
76 struct som_table_class
77   {
78     /* Set table, driver. */
79     void (*table) (struct som_entity *);
80     void (*driver) (struct outp_driver *);
81
82     /* Query columns and rows. */
83     void (*count) (int *n_columns, int *n_rows);
84     void (*area) (int *horiz, int *vert);
85     void (*width) (int *columns);
86     void (*height) (int *rows);
87     void (*columns) (int *style);
88     int (*breakable) (int row);                         /* ? */
89     void (*headers) (int *l, int *r, int *t, int *b);
90     void (*join) (int *(column[2]), int *(row[2]));     /* ? */
91     void (*cumulate) (int cumtype, int start, int *end, int max, int *actual);
92     void (*flags) (unsigned *);
93     bool (*fits_width) (int width);
94     bool (*fits_length) (int length);
95
96     /* Set columns and rows. */
97     void (*set_width) (int column, int width);          /* ? */
98     void (*set_height) (int row, int height);           /* ? */
99     void (*set_headers) (int l, int r, int t, int b);
100
101     /* Rendering. */
102     void (*title) (int x, int y);
103     void (*render) (int x1, int y1, int x2, int y2);
104   };
105
106 /* Table indexes. */
107 extern int table_num;
108 extern int subtable_num;
109
110 /* Submission. */
111 void som_new_series (void);
112 void som_submit (struct som_entity *t);
113
114 /* Miscellaneous. */
115 void som_eject_page (void);
116 void som_blank_line (void);
117
118 #endif /* som_h */