LIST: Remove WEIGHT subcommand.
[pspp-builds.git] / src / output / manager.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 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 #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   } ;
42
43 /* Entity (Table or Chart) . */
44 struct som_entity
45   {
46     const struct som_table_class *class;        /* Table class. */
47     enum som_type type;                 /* Table or Chart */
48     void *ext;                          /* Owned by table or chart class. */
49     int table_num;                      /* Table number. */
50     int subtable_num;                   /* Sub-table number. */
51     char *command_name;                 /* Command that yielded this output. */
52   };
53
54 struct som_entity *som_entity_clone (struct som_entity *);
55 void som_entity_destroy (struct som_entity *);
56
57 /* Group styles. */
58 enum
59   {
60     SOM_COL_NONE,                       /* No columns. */
61     SOM_COL_DOWN                        /* Columns down first. */
62   };
63
64 /* Cumulation types. */
65 enum
66   {
67     SOM_ROWS,                   /* Rows. */
68     SOM_COLUMNS                 /* Columns. */
69   };
70
71 /* Flags. */
72 enum
73   {
74     SOMF_NONE = 0,
75     SOMF_NO_SPACING = 01,       /* No spacing before the table. */
76     SOMF_NO_TITLE = 02          /* No title. */
77   };
78
79 /* Table class. */
80 struct outp_driver;
81 struct som_table_class
82   {
83     /* Operations on tables. */
84     void (*count) (struct som_entity *, int *n_columns, int *n_rows);
85     void (*columns) (struct som_entity *, int *style);
86     void (*headers) (struct som_entity *, int *l, int *r, int *t, int *b);
87     void (*flags) (struct som_entity *, unsigned *);
88
89     /* Creating and freeing driver-specific table rendering data. */
90     void *(*render_init) (struct som_entity *, struct outp_driver *,
91                           int l, int r, int t, int b);
92     void (*render_free) (void *);
93
94     /* Rendering operations. */
95     void (*area) (void *, int *horiz, int *vert);
96     void (*cumulate) (void *, int cumtype, int start, int *end,
97                       int max, int *actual);
98     void (*title) (void *, int x, int y, int table_num, int subtable_num,
99                    const char *command_name);
100     void (*render) (void *, int x1, int y1, int x2, int y2);
101   };
102
103 /* Submission. */
104 void som_new_series (void);
105 void som_set_command_name (const char *);
106 void som_submit (struct som_entity *t);
107
108 /* Miscellaneous. */
109 void som_eject_page (void);
110 void som_blank_line (void);
111 void som_flush (void);
112
113 #endif /* som_h */