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