cairo: Remove PangoWrapMode parameter that was always PANGO_WRAP_WORD.
[pspp] / src / output / cairo.c
index cb901258d3acaaf8f760d371f7fc6010a31de98c..4170495f3b11cbdacf5faf5f54b156da53480f08 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -110,13 +110,6 @@ struct xr_render_fsm
     void (*destroy) (struct xr_render_fsm *);
   };
 
-struct xr_color
-{
-  double red;
-  double green;
-  double blue;
-};
-
 /* Cairo output driver. */
 struct xr_driver
   {
@@ -191,7 +184,7 @@ opt (struct output_driver *d, struct string_map *options, const char *key,
    Future implementations might allow things like "yellow" and
    "sky-blue-ultra-brown"
 */
-static void
+void
 parse_color (struct output_driver *d, struct string_map *options,
             const char *key, const char *default_value,
             struct xr_color *color)
@@ -622,7 +615,7 @@ xr_driver_run_fsm (struct xr_driver *xr)
 static void
 xr_layout_cell (struct xr_driver *, const struct table_cell *,
                 int bb[TABLE_N_AXES][2], int clip[TABLE_N_AXES][2],
-                PangoWrapMode, int *width, int *height);
+                int *width, int *height);
 
 static void
 dump_line (struct xr_driver *xr, int x0, int y0, int x1, int y1)
@@ -798,10 +791,10 @@ xr_measure_cell_width (void *xr_, const struct table_cell *cell,
   bb[V][0] = 0;
   bb[V][1] = INT_MAX;
   clip[H][0] = clip[H][1] = clip[V][0] = clip[V][1] = 0;
-  xr_layout_cell (xr, cell, bb, clip, PANGO_WRAP_WORD, max_width, &h);
+  xr_layout_cell (xr, cell, bb, clip, max_width, &h);
 
   bb[H][1] = 1;
-  xr_layout_cell (xr, cell, bb, clip, PANGO_WRAP_WORD, min_width, &h);
+  xr_layout_cell (xr, cell, bb, clip, min_width, &h);
 }
 
 static int
@@ -817,7 +810,7 @@ xr_measure_cell_height (void *xr_, const struct table_cell *cell, int width)
   bb[V][0] = 0;
   bb[V][1] = INT_MAX;
   clip[H][0] = clip[H][1] = clip[V][0] = clip[V][1] = 0;
-  xr_layout_cell (xr, cell, bb, clip, PANGO_WRAP_WORD, &w, &h);
+  xr_layout_cell (xr, cell, bb, clip, &w, &h);
   return h;
 }
 
@@ -828,13 +821,13 @@ xr_draw_cell (void *xr_, const struct table_cell *cell,
   struct xr_driver *xr = xr_;
   int w, h;
 
-  xr_layout_cell (xr, cell, bb, clip, PANGO_WRAP_WORD, &w, &h);
+  xr_layout_cell (xr, cell, bb, clip, &w, &h);
 }
 \f
 static void
 xr_layout_cell (struct xr_driver *xr, const struct table_cell *cell,
                 int bb[TABLE_N_AXES][2], int clip[TABLE_N_AXES][2],
-                PangoWrapMode wrap, int *width, int *height)
+                int *width, int *height)
 {
   struct xr_font *font;
 
@@ -851,7 +844,7 @@ xr_layout_cell (struct xr_driver *xr, const struct table_cell *cell,
      : PANGO_ALIGN_CENTER));
   pango_layout_set_width (font->layout,
                           bb[H][1] == INT_MAX ? -1 : bb[H][1] - bb[H][0]);
-  pango_layout_set_wrap (font->layout, wrap);
+  pango_layout_set_wrap (font->layout, PANGO_WRAP_WORD);
 
   if (clip[H][0] != clip[H][1])
     {
@@ -875,16 +868,7 @@ xr_layout_cell (struct xr_driver *xr, const struct table_cell *cell,
       cairo_restore (xr->cairo);
     }
 
-  if (width != NULL || height != NULL)
-    {
-      int w, h;
-
-      pango_layout_get_size (font->layout, &w, &h);
-      if (width != NULL)
-        *width = w;
-      if (height != NULL)
-        *height = h;
-    }
+  pango_layout_get_size (font->layout, width, height);
 }
 
 static void
@@ -1096,7 +1080,10 @@ xr_draw_chart (const struct chart_item *chart_item, cairo_t *cr,
 
 char *
 xr_draw_png_chart (const struct chart_item *item,
-                   const char *file_name_template, int number)
+                   const char *file_name_template, int number,
+                  const struct xr_color *fg,
+                  const struct xr_color *bg
+                  )
 {
   const int width = 640;
   const int length = 480;
@@ -1117,7 +1104,10 @@ xr_draw_png_chart (const struct chart_item *item,
   surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, length);
   cr = cairo_create (surface);
 
-  cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+  cairo_set_source_rgb (cr, bg->red, bg->green, bg->blue);
+  cairo_paint (cr);
+
+  cairo_set_source_rgb (cr, fg->red, fg->green, fg->blue);
 
   xr_draw_chart (item, cr, 0.0, 0.0, width, length);