1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2009, 2010, 2011 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/>. */
17 #ifndef OUTPUT_RENDER_H
18 #define OUTPUT_RENDER_H 1
22 #include "output/table-provider.h"
26 enum render_line_style
28 RENDER_LINE_NONE, /* No line. */
29 RENDER_LINE_SINGLE, /* Single line. */
30 RENDER_LINE_DOUBLE, /* Double line. */
36 /* Measures CELL's width. Stores in *MIN_WIDTH the minimum width required
37 to avoid splitting a single word across multiple lines (normally, this
38 is the width of the longest word in the cell) and in *MAX_WIDTH the
39 minimum width required to avoid line breaks other than at new-lines. */
40 void (*measure_cell_width) (void *aux, const struct table_cell *cell,
41 int *min_width, int *max_width);
43 /* Returns the height required to render CELL given a width of WIDTH. */
44 int (*measure_cell_height) (void *aux, const struct table_cell *cell,
47 /* Draws a generalized intersection of lines in the rectangle whose
48 top-left corner is (BB[TABLE_HORZ][0], BB[TABLE_VERT][0]) and whose
49 bottom-right corner is (BB[TABLE_HORZ][1], BB[TABLE_VERT][1]).
51 STYLES is interpreted this way:
53 STYLES[TABLE_HORZ][0]: style of line from top of BB to its center.
54 STYLES[TABLE_HORZ][1]: style of line from bottom of BB to its center.
55 STYLES[TABLE_VERT][0]: style of line from left of BB to its center.
56 STYLES[TABLE_VERT][1]: style of line from right of BB to its center. */
57 void (*draw_line) (void *aux, int bb[TABLE_N_AXES][2],
58 enum render_line_style styles[TABLE_N_AXES][2]);
60 /* Draws CELL within bounding box BB. CLIP is the same as BB (the common
61 case) or a subregion enclosed by BB. In the latter case only the part
62 of the cell that lies within CLIP should actually be drawn, although BB
63 should used to determine the layout of the cell. */
64 void (*draw_cell) (void *aux, const struct table_cell *cell,
65 int bb[TABLE_N_AXES][2], int clip[TABLE_N_AXES][2]);
67 /* Auxiliary data passed to each of the above functions. */
70 /* Page size to try to fit the rendering into. Some tables will, of
71 course, overflow this size. */
72 int size[TABLE_N_AXES];
74 /* Nominal size of a character in the most common font:
75 font_size[TABLE_HORZ]: Em width.
76 font_size[TABLE_VERT]: Line spacing. */
77 int font_size[TABLE_N_AXES];
79 /* Width of different kinds of lines. */
80 int line_widths[TABLE_N_AXES][RENDER_N_LINES];
83 /* A "page" of content that is ready to be rendered.
85 A page's size is not limited to the size passed in as part of render_params.
86 Use render_break (see below) to break a too-big render_page into smaller
87 render_pages that will fit in the available space. */
88 struct render_page *render_page_create (const struct render_params *,
89 const struct table *);
91 struct render_page *render_page_ref (const struct render_page *);
92 void render_page_unref (struct render_page *);
94 int render_page_get_size (const struct render_page *, enum table_axis);
95 void render_page_draw (const struct render_page *);
96 void render_page_draw_region (const struct render_page *,
97 int x, int y, int w, int h);
99 /* An iterator for breaking render_pages into smaller chunks. */
102 struct render_page *page; /* Page being broken up. */
103 enum table_axis axis; /* Axis along which 'page' is being broken. */
104 int cell; /* Next cell. */
105 int pixel; /* Pixel offset within 'cell' (usually 0). */
106 int hw; /* Width of headers of 'page' along 'axis'. */
109 void render_break_init (struct render_break *, struct render_page *,
111 void render_break_init_empty (struct render_break *);
112 void render_break_destroy (struct render_break *);
114 bool render_break_has_next (const struct render_break *);
115 int render_break_next_size (const struct render_break *);
116 struct render_page *render_break_next (struct render_break *, int size);
118 #endif /* output/render.h */