9beefc73d412bab89017d1e2c4f565b410e0d83e
[pspp] / src / output / tab.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997, 1998, 1999, 2000, 2009, 2011, 2014 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 #ifndef OUTPUT_TAB_H
18 #define OUTPUT_TAB_H
19
20 /* Simple table class.
21
22    This is a type of table (see output/table.h) whose content is composed
23    manually by the code that generates it, by filling in cells one by one.
24 */
25
26 #include "libpspp/compiler.h"
27 #include "output/table.h"
28 #include "data/format.h"
29
30 /* Rule masks. */
31 #define TAB_RULE_TYPE_MASK   7
32 #define TAB_RULE_TYPE_SHIFT  0
33 #define TAB_RULE_STYLE_MASK  (31 << TAB_RULE_STYLE_SHIFT)
34 #define TAB_RULE_STYLE_SHIFT 3
35
36 /* Tables. */
37 struct table *tab_create (int nc, int nr, int hl, int hr, int ht, int hb);
38
39 /* Rules. */
40 void tab_hline (struct table *, int style, int x1, int x2, int y);
41 void tab_vline (struct table *, int style, int x, int y1, int y2);
42 void tab_box (struct table *, int f_h, int f_v, int i_h, int i_v,
43               int x1, int y1, int x2, int y2);
44
45 /* Cells. */
46 void tab_text (struct table *, int c, int r, unsigned opt, const char *);
47 void tab_text_format (struct table *, int c, int r, unsigned opt,
48                       const char *, ...)
49   PRINTF_FORMAT (5, 6);
50
51 void tab_joint_text (struct table *, int x1, int y1, int x2, int y2,
52                      unsigned opt, const char *);
53
54 struct footnote *tab_create_footnote (struct table *, size_t idx,
55                                       const char *content, const char *marker,
56                                       struct area_style *);
57 void tab_add_footnote (struct table *, int x, int y,
58                        const struct footnote *);
59
60 void tab_add_style (struct table *, int x, int y,
61                     const struct area_style *);
62
63 bool tab_cell_is_empty (const struct table *, int c, int r);
64
65 /* Simple output. */
66 void tab_output_text (int options, const char *string);
67 void tab_output_text_format (int options, const char *, ...)
68      PRINTF_FORMAT (2, 3);
69
70 /* For use by table-provider only. */
71 struct table_cell;
72 void tab_destroy (struct table *);
73 void tab_get_cell (const struct table *, int x, int y, struct table_cell *);
74 int tab_get_rule (const struct table *, enum table_axis, int x, int y,
75                   struct cell_color *);
76
77 #endif /* output/tab.h */
78