1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997, 1998, 1999, 2000, 2009, 2011, 2014 Free Software Foundation, Inc.
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.
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.
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/>. */
20 /* Simple table class.
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.
26 #include "libpspp/compiler.h"
27 #include "output/table.h"
28 #include "data/format.h"
30 #define TAB_STYLE_MASK (7u << (TAB_FIRST_AVAILABLE + 1))
31 #define TAB_STYLE_SHIFT (TAB_FIRST_AVAILABLE + 1)
35 /* Horizontal alignment of cell contents. */
36 TAB_RIGHT = 0 << (TAB_FIRST_AVAILABLE + 2),
37 TAB_LEFT = 1 << (TAB_FIRST_AVAILABLE + 2),
38 TAB_CENTER = 2 << (TAB_FIRST_AVAILABLE + 2),
39 TAB_HALIGN = 3 << (TAB_FIRST_AVAILABLE + 2), /* Alignment mask. */
41 /* Vertical alignment of cell contents. */
42 TAB_TOP = 0 << (TAB_FIRST_AVAILABLE + 4),
43 TAB_MIDDLE = 1 << (TAB_FIRST_AVAILABLE + 4),
44 TAB_BOTTOM = 2 << (TAB_FIRST_AVAILABLE + 4),
45 TAB_VALIGN = 3 << (TAB_FIRST_AVAILABLE + 4), /* Alignment mask. */
49 #define TAB_RULE_TYPE_MASK 7
50 #define TAB_RULE_TYPE_SHIFT 0
51 #define TAB_RULE_STYLE_MASK (31 << TAB_RULE_STYLE_SHIFT)
52 #define TAB_RULE_STYLE_SHIFT 3
58 struct pool *container;
60 /* Table title and caption, or null. */
61 int cf; /* Column factor for indexing purposes. */
65 Each array element in cc[] is ordinarily a "char *" pointer to a
66 string. If TAB_JOIN (defined in tab.c) is set in ct[] for the element,
67 however, it is a joined cell and the corresponding element of cc[]
68 points to a struct tab_joined_cell. */
69 void **cc; /* Cell contents; void *[nr][nc]. */
70 unsigned short *ct; /* Cell types; unsigned short[nr][nc]. */
71 struct area_style *styles[8];
74 unsigned char *rh; /* Horiz rules; unsigned char[nr+1][nc]. */
75 unsigned char *rv; /* Vert rules; unsigned char[nr][nc+1]. */
76 struct cell_color *rule_colors[32];
79 struct tab_table *tab_cast (const struct table *);
81 /* Number of rows or columns in TABLE. */
82 static inline int tab_nr (const struct tab_table *table)
83 { return table_nr (&table->table); }
84 static inline int tab_nc (const struct tab_table *table)
85 { return table_nc (&table->table); }
87 /* Number of left/right/top/bottom header columns/rows in TABLE. */
88 static inline int tab_l (const struct tab_table *table)
89 { return table_hl (&table->table); }
90 static inline int tab_r (const struct tab_table *table)
91 { return table_hr (&table->table); }
92 static inline int tab_t (const struct tab_table *table)
93 { return table_ht (&table->table); }
94 static inline int tab_b (const struct tab_table *table)
95 { return table_hb (&table->table); }
98 struct tab_table *tab_create (int nc, int nr);
99 void tab_headers (struct tab_table *, int l, int r, int t, int b);
102 void tab_hline (struct tab_table *, int style, int x1, int x2, int y);
103 void tab_vline (struct tab_table *, int style, int x, int y1, int y2);
104 void tab_box (struct tab_table *, int f_h, int f_v, int i_h, int i_v,
105 int x1, int y1, int x2, int y2);
108 void tab_text (struct tab_table *, int c, int r, unsigned opt, const char *);
109 void tab_text_format (struct tab_table *, int c, int r, unsigned opt,
111 PRINTF_FORMAT (5, 6);
113 void tab_joint_text (struct tab_table *, int x1, int y1, int x2, int y2,
114 unsigned opt, const char *);
116 struct footnote *tab_create_footnote (struct tab_table *, size_t idx,
117 const char *content, const char *marker,
118 struct area_style *);
119 void tab_add_footnote (struct tab_table *, int x, int y,
120 const struct footnote *);
122 void tab_add_style (struct tab_table *, int x, int y,
123 const struct area_style *);
125 bool tab_cell_is_empty (const struct tab_table *, int c, int r);
128 void tab_output_text (int options, const char *string);
129 void tab_output_text_format (int options, const char *, ...)
130 PRINTF_FORMAT (2, 3);
132 #endif /* output/tab.h */