xr->char_width = MAX (xr->char_width, pango_to_xr (char_width));
xr->char_height = MAX (xr->char_height, pango_to_xr (char_height));
}
- xr->cell_margin = xr->char_width;
+ xr->cell_margin = xr->char_width / 2;
if (xr->params == NULL)
{
cairo_stroke (xr->cairo);
}
+static void
+fill_rectangle (struct xr_driver *xr, int x0, int y0, int x1, int y1)
+{
+ cairo_new_path (xr->cairo);
+ cairo_set_line_width (xr->cairo, xr_to_pt (xr->line_width));
+ cairo_rectangle (xr->cairo,
+ xr_to_pt (x0 + xr->x), xr_to_pt (y0 + xr->y),
+ xr_to_pt (x1 - x0), xr_to_pt (y1 - y0));
+ cairo_fill (xr->cairo);
+}
+
/* Draws a horizontal line X0...X2 at Y if LEFT says so,
shortening it to X0...X1 if SHORTEN is true.
Draws a horizontal line X1...X3 at Y if RIGHT says so,
return h;
}
+static void xr_clip (struct xr_driver *, int clip[TABLE_N_AXES][2]);
+
static void
xr_draw_cell (void *xr_, const struct table_cell *cell,
int bb[TABLE_N_AXES][2], int clip[TABLE_N_AXES][2])
struct xr_driver *xr = xr_;
int w, h, brk;
+ cairo_save (xr->cairo);
+ xr_clip (xr, clip);
+ cairo_set_source_rgb (xr->cairo,
+ cell->style->bg.r / 255.,
+ cell->style->bg.g / 255.,
+ cell->style->bg.b / 255.);
+ fill_rectangle (xr, bb[H][0], bb[V][0], bb[H][1], bb[V][1]);
+ cairo_restore (xr->cairo);
+
+ cairo_save (xr->cairo);
+ cairo_set_source_rgb (xr->cairo,
+ cell->style->fg.r / 255.,
+ cell->style->fg.g / 255.,
+ cell->style->fg.b / 255.);
+
bb[H][0] += xr->cell_margin;
bb[H][1] -= xr->cell_margin;
- if (bb[H][0] >= bb[H][1])
- return;
- xr_layout_cell (xr, cell, bb, clip, &w, &h, &brk);
+ if (bb[H][0] < bb[H][1])
+ xr_layout_cell (xr, cell, bb, clip, &w, &h, &brk);
+ cairo_restore (xr->cairo);
}
static int
#ifndef OUTPUT_TABLE_PROVIDER
#define OUTPUT_TABLE_PROVIDER 1
+#include <stdint.h>
#include "output/table.h"
struct string;
void cell_contents_format_footnote_markers (const struct cell_contents *,
struct string *);
+struct cell_color
+ {
+ uint8_t r, g, b;
+ };
+
+#define CELL_COLOR(r, g, b) (struct cell_color) { r, g, b }
+#define CELL_COLOR_BLACK CELL_COLOR (0, 0, 0)
+#define CELL_COLOR_WHITE CELL_COLOR (255, 255, 255)
+
+static inline bool
+cell_color_equal (const struct cell_color *a, const struct cell_color *b)
+{
+ return a->r == b->r && a->g == b->g && a->b == b->b;
+}
+
+struct cell_style
+ {
+ struct cell_color fg, bg;
+ };
+
/* A cell in a table. */
struct table_cell
{
size_t n_contents;
struct cell_contents inline_contents;
+ const struct cell_style *style;
+
/* Called to free the cell's data, if nonnull. */
void (*destructor) (void *destructor_aux);
void *destructor_aux;