output-item: Collapse the inheritance hierarchy into a single struct.
[pspp] / src / output / cairo-pager.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2009, 2010, 2014, 2020 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_CAIRO_PAGER_H
18 #define OUTPUT_CAIRO_PAGER_H 1
19
20 #include <stdbool.h>
21
22 /* Cairo output driver paginater. */
23
24 #include <cairo/cairo.h>
25 #include <pango/pango-font.h>
26 #include "output/cairo-fsm.h"
27 #include "output/page-setup.h"
28 #include "output/table.h"
29
30 struct xr_page_style
31   {
32     int ref_cnt;
33
34     int margins[TABLE_N_AXES][2];    /* Margins. */
35
36     struct page_heading headings[2]; /* Top and bottom headings. */
37
38     int initial_page_number;
39
40     /* Whether to include an outline in PDF output.  (The only reason I know to
41        omit it is to avoid a Cairo bug that caused crashes in some cases.) */
42     bool include_outline;
43   };
44 struct xr_page_style *xr_page_style_ref (const struct xr_page_style *);
45 struct xr_page_style *xr_page_style_unshare (struct xr_page_style *);
46 void xr_page_style_unref (struct xr_page_style *);
47 bool xr_page_style_equals (const struct xr_page_style *,
48                            const struct xr_page_style *);
49 struct xr_page_style *xr_page_style_default (void);
50
51 static inline int
52 xr_page_style_paper_size (const struct xr_page_style *ps,
53                           const struct xr_fsm_style *fs, enum table_axis a)
54 {
55   return fs->size[a] + ps->margins[a][0] + ps->margins[a][1];
56 }
57
58 struct xr_pager *xr_pager_create (const struct xr_page_style *,
59                                   const struct xr_fsm_style *);
60 void xr_pager_destroy (struct xr_pager *);
61
62 bool xr_pager_has_item (const struct xr_pager *);
63 void xr_pager_add_item (struct xr_pager *, const struct output_item *);
64
65 bool xr_pager_has_page (const struct xr_pager *);
66 void xr_pager_add_page (struct xr_pager *, cairo_t *);
67 void xr_pager_finish_page (struct xr_pager *);
68 bool xr_pager_needs_new_page (struct xr_pager *);
69
70 #endif /* output/cairo-pager.h */