]> git.cworth.org Git - acre/commitdiff
Put frame and ticks into its own function as well.
authorCarl Worth <cworth@cworth.org>
Sun, 25 Jan 2009 09:03:21 +0000 (20:03 +1100)
committerCarl Worth <cworth@cworth.org>
Thu, 16 Apr 2009 19:02:59 +0000 (12:02 -0700)
acre.c

diff --git a/acre.c b/acre.c
index 6e75ab7ee8403cb537c682e069bdd0c26749850e..573569598aa413aa1b1cc94a183da18e8ef06a86 100644 (file)
--- a/acre.c
+++ b/acre.c
@@ -152,6 +152,8 @@ _draw_title_and_labels (acre_t *acre)
     int y_axis_width, y_axis_height;
     PangoRectangle new_chart;
 
+    cairo_save (cr);
+
     acre_font = pango_font_description_new ();
     pango_font_description_set_family (acre_font, ACRE_FONT_FAMILY);
     pango_font_description_set_absolute_size (acre_font,
@@ -233,6 +235,25 @@ _draw_title_and_labels (acre_t *acre)
                   acre->chart.y + acre->chart.height +
                   ACRE_FONT_SIZE + ACRE_PAD);
     pango_cairo_show_layout (cr, x_axis_layout);
+
+    cairo_restore (cr);
+}
+
+static void
+_draw_frame_and_ticks (acre_t *acre)
+{
+    cairo_t *cr = acre->cr;
+
+    cairo_save (cr);
+
+    cairo_rectangle (cr,
+                    acre->chart.x - 0.5, acre->chart.y - 0.5,
+                    acre->chart.width + 1.0, acre->chart.height + 1.0);
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgb (cr, 0, 0, 0);
+    cairo_stroke (cr);
+
+    cairo_restore (cr);
 }
 
 /* Draw the plot to the given cairo context within a user-space
@@ -255,11 +276,7 @@ acre_draw (acre_t *acre, cairo_t *cr, int width, int height)
 
     _draw_title_and_labels (acre);
 
-    cairo_rectangle (cr,
-                    acre->chart.x - 0.5, acre->chart.y - 0.5,
-                    acre->chart.width + 1.0, acre->chart.height + 1.0);
-    cairo_set_line_width (cr, 1.0);
-    cairo_stroke (cr);
+    _draw_frame_and_ticks (acre);
 }
 
 /* Create a new dataset---a collection of (x, y) datapoints. A single