summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtk_plotters.c33
-rw-r--r--gtk/gtk_print.c35
2 files changed, 42 insertions, 26 deletions
diff --git a/gtk/gtk_plotters.c b/gtk/gtk_plotters.c
index e323cb590..bc990199b 100644
--- a/gtk/gtk_plotters.c
+++ b/gtk/gtk_plotters.c
@@ -49,8 +49,7 @@ GdkDrawable *current_drawable;
GdkGC *current_gc;
cairo_t *current_cr;
-static bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+static bool nsgtk_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool nsgtk_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsgtk_plot_path(const float *p, unsigned int n, colour fill, float width,
colour c, const float transform[6]);
@@ -129,21 +128,31 @@ bool nsgtk_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *st
return true;
}
-bool nsgtk_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool nsgtk_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- nsgtk_set_colour(c);
- if (dotted)
+
+ nsgtk_set_colour(style->stroke_colour);
+
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ nsgtk_set_solid();
+ break;
+
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
nsgtk_set_dotted();
- else if (dashed)
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
nsgtk_set_dashed();
- else
- nsgtk_set_solid();
+ break;
+ }
- if (width == 0)
- width = 1;
+ if (style->stroke_width == 0)
+ cairo_set_line_width(current_cr, 1);
+ else
+ cairo_set_line_width(current_cr, style->stroke_width);
- cairo_set_line_width(current_cr, width);
cairo_move_to(current_cr, x0 + 0.5, y0 + 0.5);
cairo_line_to(current_cr, x1 + 0.5, y1 + 0.5);
cairo_stroke(current_cr);
diff --git a/gtk/gtk_print.c b/gtk/gtk_print.c
index 851b690ba..0685d2f9e 100644
--- a/gtk/gtk_print.c
+++ b/gtk/gtk_print.c
@@ -46,8 +46,7 @@
#include "utils/utils.h"
static bool nsgtk_print_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style_t *style);
-static bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed);
+bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style);
static bool nsgtk_print_plot_polygon(const int *p, unsigned int n, colour fill);
static bool nsgtk_print_plot_path(const float *p, unsigned int n, colour fill,
float width, colour c, const float transform[6]);
@@ -160,24 +159,32 @@ bool nsgtk_print_plot_rectangle(int x0, int y0, int x1, int y1, const plot_style
-bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, int width,
- colour c, bool dotted, bool dashed)
+bool nsgtk_print_plot_line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- nsgtk_print_set_colour(c);
+ nsgtk_print_set_colour(style->stroke_colour);
+
+ switch (style->stroke_type) {
+ case PLOT_OP_TYPE_SOLID: /**< Solid colour */
+ default:
+ nsgtk_print_set_solid();
+ break;
- if (dotted)
+ case PLOT_OP_TYPE_DOT: /**< Doted plot */
nsgtk_print_set_dotted();
- else if (dashed)
+ break;
+
+ case PLOT_OP_TYPE_DASH: /**< dashed plot */
nsgtk_print_set_dashed();
- else
- nsgtk_print_set_solid();
+ break;
+ }
- if (width == 0)
- width = 1;
+ if (style->stroke_width == 0)
+ cairo_set_line_width(gtk_print_current_cr, 1);
+ else
+ cairo_set_line_width(gtk_print_current_cr, style->stroke_width);
- cairo_set_line_width(gtk_print_current_cr, width);
- cairo_move_to(gtk_print_current_cr, x0, y0 - 0.5);
- cairo_line_to(gtk_print_current_cr, x1, y1 - 0.5);
+ cairo_move_to(gtk_print_current_cr, x0 + 0.5, y0 + 0.5);
+ cairo_line_to(gtk_print_current_cr, x1 + 0.5, y1 + 0.5);
cairo_stroke(gtk_print_current_cr);
return true;