From 4d6e1a622b1df731ca3d46353170e725f30ac369 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 1 Sep 2003 14:48:33 +0000 Subject: [PATCH] Added hack to save ink, by not printing within CD holes. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@288 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/print.c | 54 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 5deb8480..9e96dccc 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -126,6 +126,9 @@ static void draw_outline (PrintInfo *pi, static void clip_to_outline (PrintInfo *pi, glLabel *label); +static void clip_punchouts (PrintInfo *pi, + glLabel *label); + static void create_rectangle_path (GnomePrintContext *pc, gdouble x0, @@ -511,11 +514,13 @@ print_label (PrintInfo *pi, gnome_print_translate (pi->pc, width, 0.0); gnome_print_scale (pi->pc, -1.0, 1.0); } + + clip_to_outline (pi, label); + draw_label (pi, label, record); if (outline_flag) { draw_outline (pi, label); } - clip_to_outline (pi, label); - draw_label (pi, label, record); + clip_punchouts (pi, label); gnome_print_grestore (pi->pc); @@ -1092,6 +1097,51 @@ clip_to_outline (PrintInfo *pi, gl_debug (DEBUG_PRINT, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Clip punchouts. (Save some ink by not printing in CD holes) */ +/* */ +/* Ideally this would be done in clip_to_outline, but I am not sure how to */ +/* invert the region for gnome_print_clip, so instead, I will just draw */ +/* a white circle on top of everything else. */ +/*---------------------------------------------------------------------------*/ +static void +clip_punchouts (PrintInfo *pi, + glLabel *label) +{ + gdouble r1, r2; + gdouble waste; + glTemplate *template; + + gl_debug (DEBUG_PRINT, "START"); + + template = gl_label_get_template (label); + + switch (template->label.style) { + + case GL_TEMPLATE_STYLE_RECT: + case GL_TEMPLATE_STYLE_ROUND: + break; + + case GL_TEMPLATE_STYLE_CD: + waste = template->label.cd.waste; + r1 = template->label.cd.r1; + r2 = template->label.cd.r2; + create_ellipse_path (pi->pc, r1, r1, r2-waste, r2-waste); + gnome_print_setrgbcolor (pi->pc, 1.0, 1.0, 1.0); + gnome_print_setopacity (pi->pc, 1.0); + gnome_print_fill (pi->pc); + break; + + default: + g_warning ("Unknown template label style"); + break; + } + + gl_template_free (&template); + + gl_debug (DEBUG_PRINT, "END"); +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. Path creation utilities. */ /*---------------------------------------------------------------------------*/ -- 2.39.5