From: Jim Evins Date: Sun, 31 Aug 2003 04:48:57 +0000 (+0000) Subject: Added waste attribute to label templates. X-Git-Tag: glabels-2_3_0~609 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=580cabfe1f1dee67e3952066a24e65eda443f184;p=glabels Added waste attribute to label templates. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@280 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 2b72170d..5deb8480 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -1033,6 +1033,7 @@ clip_to_outline (PrintInfo *pi, { gdouble w, h, r; gdouble r1; + gdouble waste; glTemplate *template; gl_debug (DEBUG_PRINT, "START"); @@ -1044,36 +1045,41 @@ clip_to_outline (PrintInfo *pi, case GL_TEMPLATE_STYLE_RECT: gl_label_get_size (label, &w, &h); r = template->label.rect.r; + waste = template->label.rect.waste; if (r == 0.0) { /* simple rectangle */ - create_rectangle_path (pi->pc, 0.0, 0.0, w, h); + create_rectangle_path (pi->pc, -waste, -waste, w+waste, h+waste); } else { /* rectangle with rounded corners */ - create_rounded_rectangle_path (pi->pc, 0.0, 0.0, - w, h, r); + create_rounded_rectangle_path (pi->pc, -waste, -waste, + w+waste, h+waste, r); } gnome_print_clip (pi->pc); break; case GL_TEMPLATE_STYLE_ROUND: r1 = template->label.round.r; - create_ellipse_path (pi->pc, r1, r1, r1, r1); + waste = template->label.round.waste; + create_ellipse_path (pi->pc, r1, r1, r1+waste, r1+waste); gnome_print_clip (pi->pc); break; case GL_TEMPLATE_STYLE_CD: + waste = template->label.cd.waste; if ((template->label.cd.h == 0) && (template->label.cd.w == 0)) { /* CD style, round label w/ concentric round hole */ r1 = template->label.cd.r1; - create_ellipse_path (pi->pc, r1, r1, r1, r1); - gnome_print_clip (pi->pc); + create_ellipse_path (pi->pc, r1, r1, r1+waste, r1+waste); } else { /* Business Card CD style, clipped round label w/ hole */ gl_label_get_size (label, &w, &h); r1 = template->label.cd.r1; - create_clipped_circle_path (pi->pc, w/2, h/2, w, h, r1); - gnome_print_clip (pi->pc); + create_clipped_circle_path (pi->pc, + w/2, h/2, + w+2*waste, h+2*waste, + r1+waste); } + gnome_print_clip (pi->pc); break; default: diff --git a/glabels2/src/template.h b/glabels2/src/template.h index c70a186f..cb419d87 100644 --- a/glabels2/src/template.h +++ b/glabels2/src/template.h @@ -46,18 +46,21 @@ typedef struct { glTemplateLabelParent parent; gdouble w, h, r; /* Dimensions */ + gdouble waste; } glTemplateLabelRect; typedef struct { glTemplateLabelParent parent; gdouble r; /* Dimensions */ + gdouble waste; } glTemplateLabelRound; typedef struct { glTemplateLabelParent parent; gdouble r1, r2, w, h; /* Dimensions, w&h are for business card CDs */ + gdouble waste; } glTemplateLabelCD; typedef union { diff --git a/glabels2/src/xml-template.c b/glabels2/src/xml-template.c index bf8df991..98e30bc5 100644 --- a/glabels2/src/xml-template.c +++ b/glabels2/src/xml-template.c @@ -217,11 +217,14 @@ xml_parse_label_rectangle (xmlNodePtr label_node, gl_debug (DEBUG_TEMPLATE, "START"); + template->label.style = GL_TEMPLATE_STYLE_RECT; template->label.rect.w = gl_xml_get_prop_length (label_node, "width", 0); template->label.rect.h = gl_xml_get_prop_length (label_node, "height", 0); template->label.rect.r = gl_xml_get_prop_length (label_node, "round", 0); + template->label.rect.waste = gl_xml_get_prop_length (label_node, "waste", 0); + for (node = label_node->xmlChildrenNode; node != NULL; node = node->next) { if (xmlStrEqual (node->name, "Layout")) { @@ -249,8 +252,12 @@ xml_parse_label_round (xmlNodePtr label_node, gl_debug (DEBUG_TEMPLATE, "START"); + template->label.style = GL_TEMPLATE_STYLE_ROUND; + template->label.round.r = gl_xml_get_prop_length (label_node, "radius", 0); + template->label.round.waste = gl_xml_get_prop_length (label_node, "waste", 0); + for (node = label_node->xmlChildrenNode; node != NULL; node = node->next) { if (xmlStrEqual (node->name, "Layout")) { @@ -278,11 +285,15 @@ xml_parse_label_cd (xmlNodePtr label_node, gl_debug (DEBUG_TEMPLATE, "START"); + template->label.style = GL_TEMPLATE_STYLE_CD; + template->label.cd.r1 = gl_xml_get_prop_length (label_node, "radius", 0); template->label.cd.r2 = gl_xml_get_prop_length (label_node, "hole", 0); template->label.cd.w = gl_xml_get_prop_length (label_node, "width", 0); template->label.cd.h = gl_xml_get_prop_length (label_node, "height", 0); + template->label.cd.waste = gl_xml_get_prop_length (label_node, "waste", 0); + for (node = label_node->xmlChildrenNode; node != NULL; node = node->next) { if (xmlStrEqual (node->name, "Layout")) { @@ -470,12 +481,14 @@ xml_add_label (const glTemplate *template, gl_xml_set_prop_length (node, "width", template->label.rect.w); gl_xml_set_prop_length (node, "height", template->label.rect.h); gl_xml_set_prop_length (node, "round", template->label.rect.r); + gl_xml_set_prop_length (node, "waste", template->label.rect.waste); break; case GL_TEMPLATE_STYLE_ROUND: node = xmlNewChild(root, ns, "Label-round", NULL); xmlSetProp (node, "id", "0"); gl_xml_set_prop_length (node, "radius", template->label.round.r); + gl_xml_set_prop_length (node, "waste", template->label.round.waste); break; case GL_TEMPLATE_STYLE_CD: @@ -489,6 +502,7 @@ xml_add_label (const glTemplate *template, if (template->label.cd.h != 0.0) { gl_xml_set_prop_length (node, "height", template->label.cd.h); } + gl_xml_set_prop_length (node, "waste", template->label.cd.waste); break; default: