work on docs
[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 #include <cairo/cairo.h>
23 #include <pango/pango-font.h>
24 #include "output/table.h"
25
26 struct xr_fsm;
27 struct output_item;
28
29 /* The unit used for internal measurements is inch/(72 * XR_POINT).
30    (Thus, XR_POINT units represent one point.) */
31 #define XR_POINT PANGO_SCALE
32
33 struct xr_fsm_style
34   {
35     int ref_cnt;
36
37     int size[TABLE_N_AXES];      /* Page size. */
38     int min_break[TABLE_N_AXES]; /* Minimum cell size to allow breaking. */
39     PangoFontDescription *font;
40     struct cell_color fg;
41     bool use_system_colors;
42
43     int object_spacing;
44
45     /* Resolution, in units per inch, used for measuring font "points".  If
46        this is 72.0, for example, then 1pt = 1 device unit, which is
47        appropriate for rendering to a surface created by
48        cairo_ps_surface_create() with its default transformation matrix of 72
49        units/inch.  For a screen-based surface, it is traditionally 96.0. */
50     double font_resolution;
51   };
52 struct xr_fsm_style *xr_fsm_style_ref (const struct xr_fsm_style *);
53 struct xr_fsm_style *xr_fsm_style_unshare (struct xr_fsm_style *);
54 void xr_fsm_style_unref (struct xr_fsm_style *);
55 bool xr_fsm_style_equals (const struct xr_fsm_style *,
56                           const struct xr_fsm_style *);
57
58 /* Interface used for rendering output items in a single on-screen region. */
59 struct xr_fsm *xr_fsm_create_for_scrolling (const struct output_item *,
60                                             const struct xr_fsm_style *,
61                                             cairo_t *);
62 void xr_fsm_measure (struct xr_fsm *, cairo_t *, int *w, int *h);
63 void xr_fsm_draw_all (struct xr_fsm *, cairo_t *);
64 void xr_fsm_draw_region (struct xr_fsm *, cairo_t *,
65                          int x, int y, int w, int h);
66
67 /* Interface used for rendering output items to a series of printed pages. */
68 struct xr_fsm *xr_fsm_create_for_printing (const struct output_item *,
69                                            const struct xr_fsm_style *,
70                                            cairo_t *);
71 void xr_fsm_destroy (struct xr_fsm *);
72 int xr_fsm_draw_slice (struct xr_fsm *, cairo_t *, int space);
73 bool xr_fsm_is_empty (const struct xr_fsm *);
74
75 #endif /* output/cairo-fsm.h */