diff options
| author | Simon Tatham <anakin@pobox.com> | 2010-05-29 15:43:46 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2010-05-29 15:43:46 +0000 |
| commit | 9cd182ffa92e97609d562883a1c8e74949963ba0 (patch) | |
| tree | 43f35c00ac8d248209c3c40ebb9ac9d1a3e5e302 /gtk.c | |
| parent | ef6e78c6ac804a197cfc6002c5866885321626c5 (diff) | |
| download | puzzles-9cd182ffa92e97609d562883a1c8e74949963ba0.zip puzzles-9cd182ffa92e97609d562883a1c8e74949963ba0.tar.gz puzzles-9cd182ffa92e97609d562883a1c8e74949963ba0.tar.bz2 puzzles-9cd182ffa92e97609d562883a1c8e74949963ba0.tar.xz | |
Patch from Mark Wooding to introduce a draw_thick_line() function in
the drawing API, for use by Loopy. It's optional: drawing.c will
construct an acceptable alternative using a filled polygon if the
front end doesn't provide it.
Net and Netslide previously had static functions called
draw_thick_line(), whose claim to the name is less justified and so
they've been renamed.
[originally from svn r8962]
Diffstat (limited to 'gtk.c')
| -rw-r--r-- | gtk.c | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -40,6 +40,8 @@ # define USE_CAIRO #endif +/* #undef USE_CAIRO */ +/* #define NO_THICK_LINE */ #ifdef DEBUGGING static FILE *debug_fp = NULL; @@ -297,6 +299,18 @@ static void do_draw_line(frontend *fe, int x1, int y1, int x2, int y2) cairo_stroke(fe->cr); } +static void do_draw_thick_line(frontend *fe, float thickness, + float x1, float y1, float x2, float y2) +{ + cairo_save(fe->cr); + cairo_set_line_width(fe->cr, thickness); + cairo_new_path(fe->cr); + cairo_move_to(fe->cr, x1, y1); + cairo_line_to(fe->cr, x2, y2); + cairo_stroke(fe->cr); + cairo_restore(fe->cr); +} + static void do_draw_poly(frontend *fe, int *coords, int npoints, int fillcolour, int outlinecolour) { @@ -518,6 +532,25 @@ static void do_draw_line(frontend *fe, int x1, int y1, int x2, int y2) gdk_draw_line(fe->pixmap, fe->gc, x1, y1, x2, y2); } +static void do_draw_thick_line(frontend *fe, float thickness, + float x1, float y1, float x2, float y2) +{ + GdkGCValues save; + + gdk_gc_get_values(fe->gc, &save); + gdk_gc_set_line_attributes(fe->gc, + thickness, + GDK_LINE_SOLID, + GDK_CAP_BUTT, + GDK_JOIN_BEVEL); + gdk_draw_line(fe->pixmap, fe->gc, x1, y1, x2, y2); + gdk_gc_set_line_attributes(fe->gc, + save.line_width, + save.line_style, + save.cap_style, + save.join_style); +} + static void do_draw_poly(frontend *fe, int *coords, int npoints, int fillcolour, int outlinecolour) { @@ -850,6 +883,14 @@ void gtk_draw_line(void *handle, int x1, int y1, int x2, int y2, int colour) do_draw_line(fe, x1, y1, x2, y2); } +void gtk_draw_thick_line(void *handle, float thickness, + float x1, float y1, float x2, float y2, int colour) +{ + frontend *fe = (frontend *)handle; + set_colour(fe, colour); + do_draw_thick_line(fe, thickness, x1, y1, x2, y2); +} + void gtk_draw_poly(void *handle, int *coords, int npoints, int fillcolour, int outlinecolour) { @@ -955,6 +996,11 @@ const struct drawing_api gtk_drawing = { #else NULL, #endif +#ifdef NO_THICK_LINE + NULL, +#else + gtk_draw_thick_line, +#endif }; static void destroy(GtkWidget *widget, gpointer data) |