return x * (PANGO_SCALE * 72 / 96);
}
+/* Dimensions for drawing lines in tables. */
+#define XR_LINE_WIDTH (XR_POINT / 2) /* Width of an ordinary line. */
+#define XR_LINE_SPACE XR_POINT /* Space between double lines. */
+
/* Output types. */
enum xr_output_type
{
int *min, int *max);
static int xr_measure_cell_height (void *, const struct table_cell *,
int width);
-static void xr_draw_cell (void *, const struct table_cell *,
+static void xr_draw_cell (void *, const struct table_cell *, int color_idx,
int bb[TABLE_N_AXES][2],
int spill[TABLE_N_AXES][2],
int clip[TABLE_N_AXES][2]);
xr->fonts[XR_FONT_EMPHASIS].desc = parse_font_option (
d, o, "emph-font", "sans serif", font_size, false, true);
- xr->line_space = XR_POINT;
- xr->line_width = XR_POINT / 2;
xr->page_number = 0;
parse_color (d, o, "background-color", "#FFFFFFFFFFFF", &xr->bg);
xr->cairo = cairo;
- cairo_set_line_width (xr->cairo, xr_to_pt (xr->line_width));
+ cairo_set_line_width (xr->cairo, xr_to_pt (XR_LINE_WIDTH));
xr->char_width = 0;
xr->char_height = 0;
xr->params->font_size[H] = xr->char_width;
xr->params->font_size[V] = xr->char_height;
- int lw = xr->line_width;
- int ls = xr->line_space;
+ int lw = XR_LINE_WIDTH;
+ int ls = XR_LINE_SPACE;
for (i = 0; i < TABLE_N_AXES; i++)
{
xr->params->line_widths[i][RENDER_LINE_NONE] = 0;
color->r / 255.0, color->g / 255.0, color->b / 255.0);
cairo_set_line_width (
xr->cairo,
- xr_to_pt (style == RENDER_LINE_THICK ? xr->line_width * 2
- : style == RENDER_LINE_THIN ? xr->line_width / 2
- : xr->line_width));
+ xr_to_pt (style == RENDER_LINE_THICK ? XR_LINE_WIDTH * 2
+ : style == RENDER_LINE_THIN ? XR_LINE_WIDTH / 2
+ : XR_LINE_WIDTH));
cairo_move_to (xr->cairo, xr_to_pt (x0 + xr->x), xr_to_pt (y0 + xr->y));
cairo_line_to (xr->cairo, xr_to_pt (x1 + xr->x), xr_to_pt (y1 + xr->y));
cairo_stroke (xr->cairo);
dump_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_set_line_width (xr->cairo, xr_to_pt (XR_LINE_WIDTH));
cairo_move_to (xr->cairo, xr_to_pt (x0 + xr->x), xr_to_pt (y0 + xr->y));
cairo_line_to (xr->cairo, xr_to_pt (x1 + xr->x), xr_to_pt (y0 + xr->y));
cairo_line_to (xr->cairo, xr_to_pt (x1 + xr->x), xr_to_pt (y1 + xr->y));
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_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));
struct xr_driver *xr = xr_;
/* Offset from center of each line in a pair of double lines. */
- int double_line_ofs = (xr->line_space + xr->line_width) / 2;
+ int double_line_ofs = (XR_LINE_SPACE + XR_LINE_WIDTH) / 2;
/* Are the lines along each axis single or double?
(It doesn't make sense to have different kinds of line on the
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,
+xr_draw_cell (void *xr_, const struct table_cell *cell, int color_idx,
int bb[TABLE_N_AXES][2],
int spill[TABLE_N_AXES][2],
int clip[TABLE_N_AXES][2])
}
xr_clip (xr, bg_clip);
cairo_set_source_rgb (xr->cairo,
- cell->style->bg.r / 255.,
- cell->style->bg.g / 255.,
- cell->style->bg.b / 255.);
+ cell->style->bg[color_idx].r / 255.,
+ cell->style->bg[color_idx].g / 255.,
+ cell->style->bg[color_idx].b / 255.);
fill_rectangle (xr,
bb[H][0] - spill[H][0],
bb[V][0] - spill[V][0],
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.);
+ cell->style->fg[color_idx].r / 255.,
+ cell->style->fg[color_idx].g / 255.,
+ cell->style->fg[color_idx].b / 255.);
for (int axis = 0; axis < TABLE_N_AXES; axis++)
{
else if (is_message_item (item))
{
const struct message_item *message_item = to_message_item (item);
- const struct msg *msg = message_item_get_msg (message_item);
- char *s = msg_to_string (msg, NULL);
+ char *s = msg_to_string (message_item_get_msg (message_item));
r = xr_rendering_create_text (xr, s, cr);
free (s);
}
xr_render_text (struct xr_driver *xr, const struct text_item *text_item)
{
enum text_item_type type = text_item_get_type (text_item);
- const char *text = text_item_get_text (text_item);
switch (type)
{
- case TEXT_ITEM_TITLE:
- free (xr->title);
- xr->title = xstrdup (text);
- break;
-
- case TEXT_ITEM_SUBTITLE:
- free (xr->subtitle);
- xr->subtitle = xstrdup (text);
- break;
-
- case TEXT_ITEM_COMMAND_CLOSE:
+ case TEXT_ITEM_PAGE_TITLE:
break;
case TEXT_ITEM_BLANK_LINE:
xr_render_message (struct xr_driver *xr,
const struct message_item *message_item)
{
- const struct msg *msg = message_item_get_msg (message_item);
- char *s = msg_to_string (msg, message_item->command_name);
+ char *s = msg_to_string (message_item_get_msg (message_item));
struct text_item *item = text_item_create (TEXT_ITEM_PARAGRAPH, s);
free (s);
struct xr_render_fsm *fsm = xr_create_text_renderer (xr, item);