]> git.sur5r.net Git - glabels/commitdiff
Added waste attribute to label templates.
authorJim Evins <evins@snaught.com>
Sun, 31 Aug 2003 04:48:57 +0000 (04:48 +0000)
committerJim Evins <evins@snaught.com>
Sun, 31 Aug 2003 04:48:57 +0000 (04:48 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@280 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/print.c
glabels2/src/template.h
glabels2/src/xml-template.c

index 2b72170dd6c221cde532d22837dd3a8380bb7256..5deb84801b8d845b7685fa7c112808ebf247bfe2 100644 (file)
@@ -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:
index c70a186f8002cb122618b351513278a35ff26a2a..cb419d87bfac19734d66b88948109ee46860cf05 100644 (file)
@@ -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 {
index bf8df99171f625574b2d85dda27089ad49019a2b..98e30bc5e5edc1513c704f2da1d4df96d30d64bd 100644 (file)
@@ -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: