cairo: Factor out code for basic rendering.
[pspp] / src / output / cairo-fsm.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_FSM_H
18 #define OUTPUT_CAIRO_FSM_H 1
19
20 #include <stdbool.h>
21
22 #ifdef HAVE_CAIRO
23
24 #include <cairo/cairo.h>
25 #include <pango/pango-font.h>
26 #include "output/table.h"
27
28 struct xr_fsm;
29 struct output_item;
30
31 enum xr_font_type
32   {
33     XR_FONT_PROPORTIONAL,
34     XR_FONT_FIXED,
35     XR_N_FONTS
36   };
37
38 struct xr_fsm_style
39   {
40     int ref_cnt;
41
42     int size[TABLE_N_AXES];     /* Page size. */
43     int min_break[TABLE_N_AXES]; /* Minimum cell size to allow breaking. */
44     PangoFontDescription *fonts[XR_N_FONTS];
45     bool use_system_colors;
46     bool transparent;
47     double font_scale;
48   };
49 struct xr_fsm_style *xr_fsm_style_ref (const struct xr_fsm_style *);
50 void xr_fsm_style_unref (struct xr_fsm_style *);
51 bool xr_fsm_style_equals (const struct xr_fsm_style *,
52                           const struct xr_fsm_style *);
53
54 struct xr_fsm *xr_fsm_create (const struct output_item *,
55                               const struct xr_fsm_style *,
56                               cairo_t *);
57 void xr_fsm_destroy (struct xr_fsm *);
58
59 void xr_fsm_measure (struct xr_fsm *, cairo_t *, int *w, int *h);
60 void xr_fsm_draw_all (struct xr_fsm *, cairo_t *);
61 void xr_fsm_draw_region (struct xr_fsm *, cairo_t *,
62                          int x, int y, int w, int h);
63
64 int xr_fsm_draw_slice (struct xr_fsm *, cairo_t *, int space);
65 bool xr_fsm_is_empty (const struct xr_fsm *);
66
67 #endif  /* HAVE_CAIRO */
68
69 #endif /* output/cairo-fsm.h */