]> git.sur5r.net Git - glabels/commitdiff
Barcodes are now resizable interactively on the canvas in both width and height ...
authorJim Evins <evins@snaught.com>
Sat, 25 Jan 2003 00:43:45 +0000 (00:43 +0000)
committerJim Evins <evins@snaught.com>
Sat, 25 Jan 2003 00:43:45 +0000 (00:43 +0000)
Added checkbox to turn-off checksum digit on barcodes when it is optional.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@245 f5e0f49d-192f-0410-a22d-a8d8700d0965

16 files changed:
glabels2/src/bc-gnubarcode.c
glabels2/src/bc-gnubarcode.h
glabels2/src/bc-postnet.c
glabels2/src/bc-postnet.h
glabels2/src/bc.c
glabels2/src/bc.h
glabels2/src/label-barcode.c
glabels2/src/label-barcode.h
glabels2/src/print.c
glabels2/src/view-barcode.c
glabels2/src/view-highlight.c
glabels2/src/wdgt-bc-props.c
glabels2/src/wdgt-bc-props.h
glabels2/src/wdgt-bc-style.c
glabels2/src/wdgt-bc-style.h
glabels2/src/xml-label.c

index c97f56ff84647db1b3a875546352c573ec327acf..2bacb0d743b951fbc8728eb931c5cc0e036d8d64 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  bc-gnubarcode.c:  front-end to GNU-barcode-library module
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
  *
  *  Some of this code is borrowed from the postscript renderer (ps.c)
  *  from the GNU barcode library:
@@ -47,8 +47,8 @@
 /* Local function prototypes                 */
 /*===========================================*/
 static glBarcode *render_pass1 (struct Barcode_Item *bci,
-                               gboolean             text_flag,
-                               gdouble              scale);
+                               gint                 flags);
+
 \f
 /*****************************************************************************/
 /* Generate intermediate representation of barcode.                          */
@@ -56,7 +56,9 @@ static glBarcode *render_pass1 (struct Barcode_Item *bci,
 glBarcode *
 gl_barcode_gnubarcode_new (glBarcodeStyle  style,
                           gboolean        text_flag,
-                          gdouble         scale,
+                          gboolean        checksum_flag,
+                          gdouble         w,
+                          gdouble         h,
                           gchar          *digits)
 {
        glBarcode           *gbc;
@@ -105,6 +107,18 @@ gl_barcode_gnubarcode_new (glBarcodeStyle  style,
                flags = BARCODE_ANY;
                break;
        }
+
+       if (!text_flag) {
+               flags |= BARCODE_NO_ASCII;
+       }
+       if (!checksum_flag) {
+               flags |= BARCODE_NO_CHECKSUM;
+       }
+
+       bci->scalef = 0.0;
+       bci->width  = w;
+       bci->height = h;
+
        Barcode_Encode (bci, flags);
        if (!bci->partial || !bci->textinfo) {
                g_warning ("Barcode Data Invalid");
@@ -114,7 +128,7 @@ gl_barcode_gnubarcode_new (glBarcodeStyle  style,
 
        /* now render with our custom back-end,
           to create appropriate intermdediate format */
-       gbc = render_pass1 (bci, text_flag, scale);
+       gbc = render_pass1 (bci, flags);
 
        Barcode_Delete (bci);
        return gbc;
@@ -132,12 +146,13 @@ gl_barcode_gnubarcode_new (glBarcodeStyle  style,
  *--------------------------------------------------------------------------*/
 static glBarcode *
 render_pass1 (struct Barcode_Item *bci,
-             gboolean             text_flag,
-             gdouble              scale)
+             gint                 flags)
 {
+       gint           validbits = BARCODE_NO_ASCII;
        glBarcode     *gbc;
        glBarcodeLine *line;
        glBarcodeChar *bchar;
+       gdouble        scalef = 1.0;
        gdouble        x;
        gint           i, j, barlen;
        gdouble        f1, f2;
@@ -145,6 +160,19 @@ render_pass1 (struct Barcode_Item *bci,
        gdouble        x0, y0, yr;
        guchar        *p, c;
 
+       if (bci->width > (2*bci->margin)) {
+               bci->width -= 2*bci->margin;
+       }
+       if (bci->height > (2*bci->margin)) {
+               bci->height -= 2*bci->margin;
+       }
+
+       /* If any flag is clear in "flags", inherit it from "bci->flags" */
+       if (!(flags & BARCODE_NO_ASCII)) {
+               flags |= bci->flags & BARCODE_NO_ASCII;
+       }
+       flags = bci->flags = (flags & validbits) | (bci->flags & ~validbits);
+
        /* First calculate barlen */
        barlen = bci->partial[0] - '0';
        for (p = bci->partial + 1; *p != 0; p++) {
@@ -157,17 +185,50 @@ render_pass1 (struct Barcode_Item *bci,
                }
        }
 
+       /* The scale factor depends on bar length */
+       if (!bci->scalef) {
+               if (!bci->width) bci->width = barlen; /* default */
+               scalef = bci->scalef = (double)bci->width / (double)barlen;
+               if (scalef < 0.5) scalef = 0.5;
+       }
+
        /* The width defaults to "just enough" */
-       bci->width = barlen * scale + 1;
+       bci->width = barlen * scalef + 1;
+
+       /* But it can be too small, in this case enlarge and center the area */
+       if (bci->width < barlen * scalef) {
+               int wid = barlen * scalef + 1;
+               bci->xoff -= (wid - bci->width)/2 ;
+               bci->width = wid;
+               /* Can't extend too far on the left */
+               if (bci->xoff < 0) {
+                       bci->width += -bci->xoff;
+                       bci->xoff = 0;
+               }
+       }
 
        /* The height defaults to 80 points (rescaled) */
        if (!bci->height)
-               bci->height = 80 * scale;
+               bci->height = 80 * scalef;
+
+       /* If too small (5 + text), reduce the scale factor and center */
+       i = 5 + 10 * ((bci->flags & BARCODE_NO_ASCII)==0);
+       if (bci->height < i * scalef ) {
+#if 0
+               double scaleg = ((double)bci->height) / i;
+               int wid = bci->width * scaleg / scalef;
+               bci->xoff += (bci->width - wid)/2;
+               bci->width = wid;
+               scalef = scaleg;
+#else
+               bci->height = i * scalef;
+#endif
+       }
 
        gbc = g_new0 (glBarcode, 1);
 
        /* Now traverse the code string and create a list of lines */
-       x = bci->margin + (bci->partial[0] - '0') * scale;
+       x = bci->margin + (bci->partial[0] - '0') * scalef;
        for (p = bci->partial + 1, i = 1; *p != 0; p++, i++) {
                /* special cases: '+' and '-' */
                if (*p == '+' || *p == '-') {
@@ -181,34 +242,34 @@ render_pass1 (struct Barcode_Item *bci,
                else
                        j = *p - 'a' + 1;
                if (i % 2) {    /* bar */
-                       x0 = x + (j * scale) / 2;
+                       x0 = x + (j * scalef) / 2;
                        y0 = bci->margin;
                        yr = bci->height;
-                       if (text_flag) {        /* leave space for text */
+                       if (!(bci->flags & BARCODE_NO_ASCII)) { /* leave space for text */
                                if (mode == '-') {
                                        /* text below bars: 10 or 5 points */
-                                       yr -= (isdigit (*p) ? 10 : 5) * scale;
+                                       yr -= (isdigit (*p) ? 10 : 5) * scalef;
                                } else {        /* '+' */
                                        /* above bars: 10 or 0 from bottom,
                                           and 10 from top */
-                                       y0 += 10 * scale;
-                                       yr -= (isdigit (*p) ? 20 : 10) * scale;
+                                       y0 += 10 * scalef;
+                                       yr -= (isdigit (*p) ? 20 : 10) * scalef;
                                }
                        }
                        line = g_new0 (glBarcodeLine, 1);
                        line->x = x0;
                        line->y = y0;
                        line->length = yr;
-                       line->width = (j * scale) - SHRINK_AMOUNT;
+                       line->width = (j * scalef) - SHRINK_AMOUNT;
                        gbc->lines = g_list_append (gbc->lines, line);
                }
-               x += j * scale;
+               x += j * scalef;
 
        }
 
        /* Now the text */
        mode = '-';             /* reinstantiate default */
-       if (text_flag) {
+       if (!(bci->flags & BARCODE_NO_ASCII)) {
                for (p = bci->textinfo; p; p = strchr (p, ' ')) {
                        while (*p == ' ')
                                p++;
@@ -223,14 +284,14 @@ render_pass1 (struct Barcode_Item *bci,
                                continue;
                        }
                        bchar = g_new0 (glBarcodeChar, 1);
-                       bchar->x = f1 * scale + bci->margin;
+                       bchar->x = f1 * scalef + bci->margin;
                        if (mode == '-') {
                                bchar->y =
-                                   bci->margin + bci->height - 8 * scale;
+                                   bci->margin + bci->height - 8 * scalef;
                        } else {
                                bchar->y = bci->margin;
                        }
-                       bchar->fsize = f2 * FONT_SCALE * scale;
+                       bchar->fsize = f2 * FONT_SCALE * scalef;
                        bchar->c = c;
                        gbc->chars = g_list_append (gbc->chars, bchar);
                }
@@ -240,5 +301,9 @@ render_pass1 (struct Barcode_Item *bci,
        gbc->height = bci->height + 2.0 * bci->margin;
        gbc->width = bci->width + 2.0 * bci->margin;
 
+#if 0
+       g_print ("w=%f, h=%f\n", gbc->width, gbc->height);
+#endif
+
        return gbc;
 }
index 3dc8cf6cacf64793e0d60ec922e812352167a526..ab186eedc28b80fdeed739e6ad5e604bcbd6785a 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  bc_gnubarcode.h:  front-end to GNU-barcode-library module header file
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -28,7 +28,9 @@ G_BEGIN_DECLS
 
 glBarcode *gl_barcode_gnubarcode_new (glBarcodeStyle  style,
                                      gboolean        text_flag,
-                                     gdouble         scale,
+                                     gboolean        checksum_flag,
+                                     gdouble         w,
+                                     gdouble         h,
                                      gchar          *digits);
 
 G_END_DECLS
index 2bea1ae39d9d7e964b8ac68cb5b133cff11ffdc5..c333b2d19e75fd2de3f45af3a90eb041b53f6d70 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  bc_postnet.c:  GLabels POSTNET barcode module
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -72,7 +72,12 @@ static gchar *postnet_code (gchar *digits);
 /* Generate list of lines that form the barcode for the given digits.       */
 /****************************************************************************/
 glBarcode *
-gl_barcode_postnet_new (gchar *digits)
+gl_barcode_postnet_new (glBarcodeStyle  style,
+                       gboolean        text_flag,
+                       gboolean        checksum_flag,
+                       gdouble         w,
+                       gdouble         h,
+                       gchar          *digits)
 {
        gchar         *code, *p;
        glBarcode     *gbc;
index 63c17265a7b1059f56e984875f89dcc25062dfbd..717f1043f8bcaf684cd12b9383bfab816a7ecc35 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  bc_postnet.h:  GLabels POSTNET barcode module header file
  *
- *  Copyright (C) 2001  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 
 G_BEGIN_DECLS
 
-glBarcode *gl_barcode_postnet_new (gchar *digits);
+glBarcode *gl_barcode_postnet_new (glBarcodeStyle  style,
+                                  gboolean        text_flag,
+                                  gboolean        checksum_flag,
+                                  gdouble         w,
+                                  gdouble         h,
+                                  gchar          *digits);
 
 G_END_DECLS
 
index 93215e113e3fb2585b727844f8366339786cf3cf..8c431f1ba3527357d068463368b5a709973343f4 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  bc.c:  GLabels barcode module
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include "bc-gnubarcode.h"
 
 #include "debug.h"
+
+/*========================================================*/
+/* Private macros and constants.                          */
+/*========================================================*/
+
+/*========================================================*/
+/* Private types.                                         */
+/*========================================================*/
+
+typedef struct {
+       gchar            *name;
+       glBarcodeNewFunc  new;
+       gboolean          can_text;
+       gboolean          text_optional;
+       gboolean          can_checksum;
+       gboolean          checksum_optional;
+       gchar            *default_digits;
+} Backend;
+
+
+/*========================================================*/
+/* Private globals.                                       */
+/*========================================================*/
+
+Backend backends[GL_BARCODE_N_STYLES] = {
+
+       { "POSTNET", gl_barcode_postnet_new,
+         FALSE, FALSE, TRUE, FALSE, "000000000"},
+
+       { "EAN", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "000000000000 00000"},
+
+       { "UPC", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, FALSE, "00000000000 00000"},
+
+       { "ISBN", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0-00000-000-0 00000"},
+
+       { "Code39", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+       { "Code128", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+       { "Code128C", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+       { "Code128B", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+       { "I25", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+       { "CBR", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+       { "MSI", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+       { "PLS", gl_barcode_gnubarcode_new,
+         TRUE, TRUE, TRUE, TRUE, "0000000000"},
+
+};
+
+/*========================================================*/
+/* Private function prototypes.                           */
+/*========================================================*/
+
 \f
 /*****************************************************************************/
 /* Call appropriate barcode backend to create barcode in intermediate format.*/
 glBarcode *
 gl_barcode_new (glBarcodeStyle  style,
                gboolean        text_flag,
-               gdouble         scale,
+               gboolean        checksum_flag,
+               gdouble         w,
+               gdouble         h,
                gchar          *digits)
 {
        glBarcode *gbc;
 
-       switch (style) {
+       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), NULL);
+       g_return_val_if_fail (digits!=NULL, NULL);
 
-       case GL_BARCODE_STYLE_POSTNET:
-               /* Use the POSTNET backend module */
-               gbc = gl_barcode_postnet_new (digits);
-               break;
+       gbc = backends[style].new (style,
+                                  text_flag,
+                                  checksum_flag,
+                                  w,
+                                  h,
+                                  digits);
 
-       default:
-               /* Use the GNU barcode library backend */
-               gbc = gl_barcode_gnubarcode_new (style,
-                                                text_flag,
-                                                scale,
-                                                digits);
-               break;
-
-       }
        return gbc;
 }
-\f
+
 /*****************************************************************************/
 /* Free previously created barcode.                                          */
 /*****************************************************************************/
@@ -85,36 +149,87 @@ gl_barcode_free (glBarcode **gbc)
                *gbc = NULL;
        }
 }
-\f
+
+/*****************************************************************************/
+/* Get a list of names for valid barcode styles.                             */
+/*****************************************************************************/
+GList *
+gl_barcode_get_styles_list  (void)
+{
+       glBarcodeStyle  style;
+       GList          *list = NULL;
+
+       for (style=0; style <GL_BARCODE_N_STYLES; style++) {
+               list = g_list_append (list, g_strdup (backends[style].name));
+       }
+
+       return list;
+}
+
+/*****************************************************************************/
+/* Free up a previously allocated list of style names.                       */
+/*****************************************************************************/
+void
+gl_barcode_free_styles_list (GList *styles_list)
+{
+       GList *p;
+
+       for (p=styles_list; p != NULL; p=p->next) {
+               g_free (p->data);
+               p->data = NULL;
+       }
+
+       g_list_free (styles_list);
+}
+
+
 /*****************************************************************************/
 /* Return an appropriate set of digits for the given barcode style.          */
 /*****************************************************************************/
 gchar *
 gl_barcode_default_digits (glBarcodeStyle style)
 {
-       switch (style) {
-
-       case GL_BARCODE_STYLE_POSTNET:
-               return g_strdup ("000000000");
-       case GL_BARCODE_STYLE_EAN:
-               return g_strdup ("000000000000 00000");
-       case GL_BARCODE_STYLE_UPC:
-               return g_strdup ("00000000000 00000");
-       case GL_BARCODE_STYLE_ISBN:
-               return g_strdup ("0-00000-000-0 00000");
-       case GL_BARCODE_STYLE_39:
-       case GL_BARCODE_STYLE_128:
-       case GL_BARCODE_STYLE_128C:
-       case GL_BARCODE_STYLE_128B:
-       case GL_BARCODE_STYLE_I25:
-       case GL_BARCODE_STYLE_CBR:
-       case GL_BARCODE_STYLE_MSI:
-       case GL_BARCODE_STYLE_PLS:
-               return g_strdup ("0000000000");
-       default:
-               return g_strdup ("0");
-       }
+       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), "0");
 
+       return g_strdup (backends[style].default_digits);
+}
+
+/*****************************************************************************/
+/* Query text capabilities.                                                  */
+/*****************************************************************************/
+gboolean
+gl_barcode_can_text (glBarcodeStyle  style)
+{
+       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
+
+       return backends[style].can_text;
+}
+
+gboolean
+gl_barcode_text_optional (glBarcodeStyle  style)
+{
+       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
+
+       return backends[style].text_optional;
+}
+
+/*****************************************************************************/
+/* Query checksum capabilities.                                              */
+/*****************************************************************************/
+gboolean
+gl_barcode_can_csum (glBarcodeStyle  style)
+{
+       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
+
+       return backends[style].can_checksum;
+}
+
+gboolean
+gl_barcode_csum_optional (glBarcodeStyle  style)
+{
+       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), FALSE);
+
+       return backends[style].checksum_optional;
 }
 
 /*****************************************************************************/
@@ -123,35 +238,9 @@ gl_barcode_default_digits (glBarcodeStyle style)
 const gchar *
 gl_barcode_style_to_text (glBarcodeStyle style)
 {
-       switch (style) {
-       case GL_BARCODE_STYLE_POSTNET:
-               return "POSTNET";
-       case GL_BARCODE_STYLE_EAN:
-               return "EAN";
-       case GL_BARCODE_STYLE_UPC:
-               return "UPC";
-       case GL_BARCODE_STYLE_ISBN:
-               return "ISBN";
-       case GL_BARCODE_STYLE_39:
-               return "Code39";
-       case GL_BARCODE_STYLE_128:
-               return "Code128";
-       case GL_BARCODE_STYLE_128C:
-               return "Code128C";
-       case GL_BARCODE_STYLE_128B:
-               return "Code128B";
-       case GL_BARCODE_STYLE_I25:
-               return "I25";
-       case GL_BARCODE_STYLE_CBR:
-               return "CBR";
-       case GL_BARCODE_STYLE_MSI:
-               return "MSI";
-       case GL_BARCODE_STYLE_PLS:
-               return "PLS";
-       default:
-               g_warning( "Illegal barcode style %d", style );
-               return "?";
-       }
+       g_return_val_if_fail ((style>=0) && (style<GL_BARCODE_N_STYLES), NULL);
+
+       return backends[style].name;
 }
 
 /*****************************************************************************/
@@ -161,44 +250,14 @@ glBarcodeStyle
 gl_barcode_text_to_style (const gchar *text)
 {
 
-       if (g_strcasecmp (text, "POSTNET") == 0) {
-               return GL_BARCODE_STYLE_POSTNET;
-       }
-       if (g_strcasecmp (text, "EAN") == 0) {
-               return GL_BARCODE_STYLE_EAN;
-       }
-       if (g_strcasecmp (text, "UPC") == 0) {
-               return GL_BARCODE_STYLE_UPC;
-       }
-       if (g_strcasecmp (text, "ISBN") == 0) {
-               return GL_BARCODE_STYLE_ISBN;
-       }
-       if (g_strcasecmp (text, "Code39") == 0) {
-               return GL_BARCODE_STYLE_39;
-       }
-       if (g_strcasecmp (text, "Code128") == 0) {
-               return GL_BARCODE_STYLE_128;
-       }
-       if (g_strcasecmp (text, "Code128C") == 0) {
-               return GL_BARCODE_STYLE_128C;
-       }
-       if (g_strcasecmp (text, "Code128B") == 0) {
-               return GL_BARCODE_STYLE_128B;
-       }
-       if (g_strcasecmp (text, "I25") == 0) {
-               return GL_BARCODE_STYLE_I25;
-       }
-       if (g_strcasecmp (text, "CBR") == 0) {
-               return GL_BARCODE_STYLE_CBR;
-       }
-       if (g_strcasecmp (text, "MSI") == 0) {
-               return GL_BARCODE_STYLE_MSI;
-       }
-       if (g_strcasecmp (text, "PLS") == 0) {
-               return GL_BARCODE_STYLE_PLS;
-       } else {
-               g_warning( "Unknown barcode style text \"%s\"", text );
-               return GL_BARCODE_STYLE_POSTNET;
+       glBarcodeStyle  style;
+
+       for (style=0; style <GL_BARCODE_N_STYLES; style++) {
+               if (g_strcasecmp (text, backends[style].name) == 0) {
+                       return style;
+               }
        }
 
+       g_warning( "Unknown barcode style text \"%s\"", text );
+       return GL_BARCODE_STYLE_POSTNET;
 }
index a8bbf5d00b98aa982d9b91e8ff9a1ca68d12630c..03c1a059274b87ca22e5b60464b990aeada31e34 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  bc.h:  GLabels barcode module header file
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -36,10 +36,11 @@ typedef enum {
        GL_BARCODE_STYLE_128C,
        GL_BARCODE_STYLE_128B,
        GL_BARCODE_STYLE_I25,
-       GL_BARCODE_STYLE_128RAW,
        GL_BARCODE_STYLE_CBR,
        GL_BARCODE_STYLE_MSI,
        GL_BARCODE_STYLE_PLS,
+
+       GL_BARCODE_N_STYLES
 } glBarcodeStyle;
 
 typedef struct {
@@ -57,21 +58,40 @@ typedef struct {
        GList *chars;           /* List of glBarcodeChar */
 } glBarcode;
 
+typedef glBarcode *(*glBarcodeNewFunc) (glBarcodeStyle  style,
+                                       gboolean        text_flag,
+                                       gboolean        checksum_flag,
+                                       gdouble         w,
+                                       gdouble         h,
+                                       gchar          *digits);
+
+
 #define GL_BARCODE_FONT_FAMILY      "Helvetica"
 #define GL_BARCODE_FONT_WEIGHT      GNOME_FONT_BOOK
 
 
-glBarcode       *gl_barcode_new              (glBarcodeStyle style,
-                                             gboolean       text_flag,
-                                             gdouble        scale,
-                                             gchar         *digits);
+glBarcode       *gl_barcode_new              (glBarcodeStyle  style,
+                                             gboolean        text_flag,
+                                             gboolean        checksum_flag,
+                                             gdouble         w,
+                                             gdouble         h,
+                                             gchar          *digits);
+
+void             gl_barcode_free             (glBarcode     **bc);
+
+GList           *gl_barcode_get_styles_list  (void);
+void             gl_barcode_free_styles_list (GList          *styles_list);
+
+gchar           *gl_barcode_default_digits   (glBarcodeStyle  style);
 
-void             gl_barcode_free             (glBarcode **bc);
+gboolean         gl_barcode_can_text         (glBarcodeStyle  style);
+gboolean         gl_barcode_text_optional    (glBarcodeStyle  style);
 
-gchar           *gl_barcode_default_digits   (glBarcodeStyle style);
+gboolean         gl_barcode_can_csum         (glBarcodeStyle  style);
+gboolean         gl_barcode_csum_optional    (glBarcodeStyle  style);
 
-const gchar     *gl_barcode_style_to_text    (glBarcodeStyle style);
-glBarcodeStyle   gl_barcode_text_to_style    (const gchar *text);
+const gchar     *gl_barcode_style_to_text    (glBarcodeStyle  style);
+glBarcodeStyle   gl_barcode_text_to_style    (const gchar    *text);
 
 G_END_DECLS
 
index c907d1938ccd9c4389469ca5f72d5c4125d527fc..e0ae915f571a80e18f7b2029ccc8cc298e23fd56 100644 (file)
@@ -42,14 +42,14 @@ struct _glLabelBarcodePrivate {
        glBarcodeStyle  style;
        guint           color;
        gboolean        text_flag;
-       gdouble         scale;
+       gboolean        checksum_flag;
 };
 
 /*========================================================*/
 /* Private globals.                                       */
 /*========================================================*/
 
-static GObjectClass *parent_class = NULL;
+static glLabelObjectClass *parent_class = NULL;
 
 static guint instance = 0;
 
@@ -159,6 +159,7 @@ copy (glLabelObject *dst_object,
        glTextNode          *text_node;
        glBarcodeStyle       style;
        gboolean             text_flag;
+       gboolean             checksum_flag;
        guint                color;
        gdouble              scale;
 
@@ -168,10 +169,10 @@ copy (glLabelObject *dst_object,
        g_return_if_fail (new_lbc && GL_IS_LABEL_BARCODE (new_lbc));
 
        text_node = gl_label_barcode_get_data (lbc);
-       gl_label_barcode_get_props (lbc, &style, &text_flag, &color, &scale);
+       gl_label_barcode_get_props (lbc, &style, &text_flag, &checksum_flag, &color);
 
        gl_label_barcode_set_data (new_lbc, text_node);
-       gl_label_barcode_set_props (new_lbc,style, text_flag, color, scale);
+       gl_label_barcode_set_props (new_lbc,style, text_flag, checksum_flag, color);
 
        gl_text_node_free (&text_node);
 
@@ -202,8 +203,8 @@ void
 gl_label_barcode_set_props (glLabelBarcode *lbc,
                            glBarcodeStyle  style,
                            gboolean        text_flag,
-                           guint           color,
-                           gdouble         scale)
+                           gboolean        checksum_flag,
+                           guint           color)
 {
        gl_debug (DEBUG_LABEL, "START");
 
@@ -211,8 +212,8 @@ gl_label_barcode_set_props (glLabelBarcode *lbc,
 
        lbc->private->style            = style;
        lbc->private->text_flag        = text_flag;
+       lbc->private->checksum_flag    = checksum_flag;
        lbc->private->color            = color;
-       lbc->private->scale            = scale;
 
        gl_label_object_emit_changed (GL_LABEL_OBJECT(lbc));
 
@@ -235,15 +236,15 @@ void
 gl_label_barcode_get_props (glLabelBarcode *lbc,
                            glBarcodeStyle *style,
                            gboolean       *text_flag,
-                           guint          *color,
-                           gdouble        *scale)
+                           gboolean       *checksum_flag,
+                           guint          *color)
 {
        g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
 
        *style            = lbc->private->style;
        *text_flag        = lbc->private->text_flag;
+       *checksum_flag    = lbc->private->checksum_flag;
        *color            = lbc->private->color;
-       *scale            = lbc->private->scale;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -256,22 +257,45 @@ get_size (glLabelObject *object,
 {
        glLabelBarcode      *lbc = (glLabelBarcode *)object;
        gchar               *data;
+       gdouble              w_parent, h_parent;
        glBarcode           *gbc;
 
        gl_debug (DEBUG_LABEL, "START");
 
        g_return_if_fail (lbc && GL_IS_LABEL_BARCODE (lbc));
 
-       data = gl_barcode_default_digits (lbc->private->style);
+       (* parent_class->get_size) (object, &w_parent, &h_parent);
+
+
+       if (lbc->private->text_node->field_flag) {
+               data = gl_barcode_default_digits (lbc->private->style);
+       } else {
+               data = gl_text_node_expand (lbc->private->text_node, NULL);
+       }
+
        gbc = gl_barcode_new (lbc->private->style,
                              lbc->private->text_flag,
-                             lbc->private->scale,
+                             lbc->private->checksum_flag,
+                             w_parent,
+                             h_parent,
                              data);
 
+       if ( gbc == NULL ) {
+               /* Try again with default digits. */
+               data = gl_barcode_default_digits (lbc->private->style);
+               gbc = gl_barcode_new (lbc->private->style,
+                                     lbc->private->text_flag,
+                                     lbc->private->checksum_flag,
+                                     w_parent,
+                                     h_parent,
+                                     data);
+       }
+
        *w = gbc->width;
        *h = gbc->height;
 
        gl_barcode_free (&gbc);
+       g_free (data);
 
        gl_debug (DEBUG_LABEL, "END");
 }
index cbe773a5a0c5780d9fb1c208f4e419c15c95ece9..4fbecea0a8fd92bc679116ebd931163a384cb048 100644 (file)
@@ -63,15 +63,15 @@ void            gl_label_barcode_set_data  (glLabelBarcode *lbc,
 void            gl_label_barcode_set_props (glLabelBarcode *lbc,
                                            glBarcodeStyle  style,
                                            gboolean        text_flag,
-                                           guint           color,
-                                           gdouble         scale);
+                                           gboolean        checksum_flag,
+                                           guint           color);
 
 glTextNode     *gl_label_barcode_get_data  (glLabelBarcode *lbc);
 void            gl_label_barcode_get_props (glLabelBarcode *lbc,
                                            glBarcodeStyle *style,
                                            gboolean       *text_flag,
-                                           guint          *color,
-                                           gdouble        *scale);
+                                           gboolean       *checksum_flag,
+                                           guint          *color);
 
 G_END_DECLS
 
index 1807d95983ade828f0638b64aa7dc0e61ae277a5..0e62f2151b7c60f384951f6ec3577a99986a3bed 100644 (file)
@@ -875,17 +875,19 @@ draw_barcode_object (PrintInfo      *pi,
        glTextNode          *text_node;
        glBarcodeStyle      style;
        gboolean            text_flag;
+       gboolean            checksum_flag;
        guint               color;
-       gdouble             scale;
+       gdouble             w, h;
 
        gl_debug (DEBUG_PRINT, "START");
 
        text_node = gl_label_barcode_get_data (object);
        gl_label_barcode_get_props (object,
-                                   &style, &text_flag, &color, &scale);
+                                   &style, &text_flag, &checksum_flag, &color);
+       gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
 
        text = gl_text_node_expand (text_node, record);
-       gbc = gl_barcode_new (style, text_flag, scale, text);
+       gbc = gl_barcode_new (style, text_flag, checksum_flag, w, h, text);
        g_free (text);
        gl_text_node_free (&text_node);
 
index e22bfc5a49e13e88c52deddf4a9a9c3704edbc92..a2312d137697eeea19dd8d1800ebf0af9a8f25f4 100644 (file)
@@ -199,7 +199,7 @@ gl_view_barcode_new (glLabelBarcode *object,
        gl_view_object_set_view (GL_VIEW_OBJECT(view_barcode), view);
        gl_view_object_set_object (GL_VIEW_OBJECT(view_barcode),
                                   GL_LABEL_OBJECT(object),
-                                  GL_VIEW_HIGHLIGHT_SIMPLE);
+                                  GL_VIEW_HIGHLIGHT_BOX_RESIZABLE);
 
        /* Create analogous canvas items. */
        draw_barcode (view_barcode);
@@ -245,8 +245,8 @@ construct_properties_dialog (glViewObject *view_object)
        glTextNode         *text_node;
        glBarcodeStyle     style;
        gboolean           text_flag;
+       gboolean           checksum_flag;
        guint              color;
-       gdouble            scale;
        glMerge            *merge;
        GtkSizeGroup       *label_size_group;
        GtkWidget          *window;
@@ -258,7 +258,7 @@ construct_properties_dialog (glViewObject *view_object)
        gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
        text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &color, &scale);
+                                   &style, &text_flag, &checksum_flag, &color);
        gl_label_get_size (GL_LABEL(object->parent),
                           &label_width, &label_height);
        merge = gl_label_get_merge (GL_LABEL(object->parent));
@@ -311,7 +311,7 @@ construct_properties_dialog (glViewObject *view_object)
        gl_wdgt_bc_style_set_label_size_group (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
                                               label_size_group);
        gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style),
-                                    style, text_flag);
+                                    style, text_flag, checksum_flag);
        gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
                                    view_barcode->private->bc_style);
        g_signal_connect (G_OBJECT (view_barcode->private->bc_style),
@@ -324,7 +324,7 @@ construct_properties_dialog (glViewObject *view_object)
        gl_wdgt_bc_props_set_label_size_group (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
                                               label_size_group);
        gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
-                                    scale, color);
+                                    color);
        gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
                                    view_barcode->private->bc_props);
        g_signal_connect ( G_OBJECT(view_barcode->private->bc_props),
@@ -439,22 +439,21 @@ bc_props_changed_cb (glWdgtBCProps  *text_props,
        glLabelObject      *object;
        glBarcodeStyle     style;
        gboolean           text_flag;
+       gboolean           checksum_flag;
        guint              color;
-       gdouble            scale;
-
 
        gl_debug (DEBUG_VIEW, "START");
 
        object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
 
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &color, &scale);
-       gl_wdgt_bc_props_get_params (text_props, &scale, &color);
+                                   &style, &text_flag, &checksum_flag, &color);
+       gl_wdgt_bc_props_get_params (text_props, &color);
 
        g_signal_handlers_block_by_func (G_OBJECT(object),
                                         update_dialog_cb, view_barcode);
        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                   style, text_flag, color, scale);
+                                   style, text_flag, checksum_flag, color);
        g_signal_handlers_unblock_by_func (G_OBJECT(object),
                                           update_dialog_cb, view_barcode);
 
@@ -471,8 +470,8 @@ bc_style_changed_cb (glWdgtBCStyle  *bc_style,
        glLabelObject      *object;
        glBarcodeStyle     style;
        gboolean           text_flag;
+       gboolean           checksum_flag;
        guint              color;
-       gdouble            scale;
 
 
        gl_debug (DEBUG_VIEW, "START");
@@ -480,13 +479,13 @@ bc_style_changed_cb (glWdgtBCStyle  *bc_style,
        object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
 
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &color, &scale);
-       gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag);
+                                   &style, &text_flag, &checksum_flag, &color);
+       gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag, &checksum_flag);
 
        g_signal_handlers_block_by_func (G_OBJECT(object),
                                         update_dialog_cb, view_barcode);
        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                   style, text_flag, color, scale);
+                                   style, text_flag, checksum_flag, color);
        g_signal_handlers_unblock_by_func (G_OBJECT(object),
                                           update_dialog_cb, view_barcode);
 
@@ -498,7 +497,7 @@ bc_style_changed_cb (glWdgtBCStyle  *bc_style,
 /*---------------------------------------------------------------------------*/
 static void
 position_changed_cb (glWdgtPosition     *position,
-                    glViewBarcode         *view_barcode)
+                    glViewBarcode      *view_barcode)
 {
        glLabelObject      *object;
        gdouble            x, y;
@@ -529,8 +528,8 @@ update_dialog_cb (glLabelObject  *object,
        glTextNode         *text_node;
        glBarcodeStyle     style;
        gboolean           text_flag;
+       gboolean           checksum_flag;
        guint              color;
-       gdouble            scale;
        glMerge            *merge;
 
        gl_debug (DEBUG_VIEW, "START");
@@ -538,7 +537,7 @@ update_dialog_cb (glLabelObject  *object,
        /* Query properties of object. */
        text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &color, &scale);
+                                   &style, &text_flag, &checksum_flag, &color);
        gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
        merge = gl_label_get_merge (GL_LABEL(object->parent));
 
@@ -560,9 +559,9 @@ update_dialog_cb (glLabelObject  *object,
        gl_wdgt_bc_data_set_field_defs (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
                                        merge);
        gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
-                                    scale, color);
+                                    color);
        gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
-                                    style, text_flag);
+                                    style, text_flag, checksum_flag);
        gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position),
                                       x, y);
 
@@ -753,8 +752,9 @@ draw_barcode (glViewBarcode *view_barcode)
        glTextNode *text_node;
        glBarcodeStyle style;
        gboolean text_flag;
+       gboolean checksum_flag;
        guint color;
-       gdouble scale;
+       gdouble w, h;
        glBarcodeLine *line;
        glBarcodeChar *bchar;
        glBarcode *gbc;
@@ -771,7 +771,8 @@ draw_barcode (glViewBarcode *view_barcode)
        /* Query label object and properties */
        object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode));
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &color, &scale);
+                                   &style, &text_flag, &checksum_flag, &color);
+       gl_label_object_get_size (object, &w, &h);
        text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object));
        if (text_node->field_flag) {
                digits = gl_barcode_default_digits (style);
@@ -795,7 +796,7 @@ draw_barcode (glViewBarcode *view_barcode)
                                                          FALSE,
                                                          10.0);
 
-       gbc = gl_barcode_new (style, text_flag, scale, digits);
+       gbc = gl_barcode_new (style, text_flag, checksum_flag, w, h, digits);
        if (gbc == NULL) {
 
                cstring = _("Invalid barcode");
index d25b10f8653257a2b74953a9f043344c42132ff0..5274656b9548245a3ad021d480e85c4ce55011dc 100644 (file)
@@ -102,6 +102,14 @@ static void   update_resizable_line              (glViewHighlight        *view_h
 static void   update_simple                      (glViewHighlight        *view_highlight);
 
 
+static void   get_origin_and_corners             (glViewHighlight        *view_highlight,
+                                                 gdouble                *x0,
+                                                 gdouble                *y0,
+                                                 gdouble                *x1,
+                                                 gdouble                *y1,
+                                                 gdouble                *x2,
+                                                 gdouble                *y2);
+
 static int tl_resize_event_handler (GnomeCanvasItem *handle_item,
                                    GdkEvent        *event,
                                    glViewHighlight *view_highlight);
@@ -929,7 +937,36 @@ update_simple (glViewHighlight *view_highlight)
 }
 
 /*---------------------------------------------------------------------------*/
-/* PRIVATE.  "Top-left" Resize event handler.                    */
+/* PRIVATE.  Get origin and corners relative to object.                      */
+/*---------------------------------------------------------------------------*/
+static void
+get_origin_and_corners (glViewHighlight *view_highlight,
+                       gdouble         *x0,
+                       gdouble         *y0,
+                       gdouble         *x1,
+                       gdouble         *y1,
+                       gdouble         *x2,
+                       gdouble         *y2)
+{
+       glLabelObject *object;
+
+       object = view_highlight->private->object;;
+
+       /* origin, relative to item */
+       gl_label_object_get_position (object, x0, y0);
+       gnome_canvas_item_w2i (view_highlight->private->group, x0, y0);
+
+       /* Top left corner, relative to item */
+       *x1 = 0.0;
+       *y1 = 0.0;
+
+       /* Bottom right corner, relative to item */
+       gl_label_object_get_size (object, x2, y2);
+}
+                    
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  "Top-left" Resize event handler.                                */
 /*---------------------------------------------------------------------------*/
 static int
 tl_resize_event_handler (GnomeCanvasItem *handle_item,
@@ -949,18 +986,6 @@ tl_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -982,6 +1007,8 @@ tl_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1003,6 +1030,8 @@ tl_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        x1 = MIN (event->motion.x, x2 - MIN_ITEM_SIZE);
@@ -1060,18 +1089,6 @@ tr_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1093,6 +1110,8 @@ tr_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1114,6 +1133,8 @@ tr_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        /* x1 unchanged */
@@ -1171,18 +1192,6 @@ bl_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1204,6 +1213,8 @@ bl_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1225,6 +1236,8 @@ bl_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        x1 = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
@@ -1282,18 +1295,6 @@ br_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1317,6 +1318,8 @@ br_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1339,6 +1342,8 @@ br_resize_event_handler (GnomeCanvasItem *handle_item,
        case GDK_MOTION_NOTIFY:
                gl_debug (DEBUG_VIEW, "MOTION_NOTIFY");
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        /* x1 unchanged */
@@ -1399,18 +1404,6 @@ sl_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1432,6 +1425,8 @@ sl_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1453,6 +1448,8 @@ sl_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        x1 = MIN (event->button.x, x2 - MIN_ITEM_SIZE);
@@ -1510,18 +1507,6 @@ sr_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1543,6 +1528,8 @@ sr_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1564,6 +1551,8 @@ sr_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        /* x1 unchanged */
@@ -1621,18 +1610,6 @@ st_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1654,6 +1631,8 @@ st_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1675,6 +1654,8 @@ st_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        /* x1 unchanged */
@@ -1732,18 +1713,6 @@ sb_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1765,6 +1734,8 @@ sb_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1786,6 +1757,8 @@ sb_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        /* x1 unchanged */
@@ -1843,18 +1816,6 @@ p1_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1876,6 +1837,8 @@ p1_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -1897,6 +1860,8 @@ p1_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        x1 = event->button.x;
@@ -1954,18 +1919,6 @@ p2_resize_event_handler (GnomeCanvasItem *handle_item,
 
        object = view_highlight->private->object;;
 
-       /* origin, relative to item */
-       gl_label_object_get_position (object, &x0, &y0);
-       gnome_canvas_item_w2i (view_highlight->private->group, &x0, &y0);
-
-       /* Top left corner, relative to item */
-       x1 = 0.0;
-       y1 = 0.0;
-
-       /* Bottom right corner, relative to item */
-       gl_label_object_get_size (object, &x2, &y2);
-
-
        switch (event->type) {
 
        case GDK_BUTTON_PRESS:
@@ -1987,6 +1940,8 @@ p2_resize_event_handler (GnomeCanvasItem *handle_item,
                switch (event->button.button) {
                case 1:
                        dragging = FALSE;
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_ungrab (handle_item,
                                                  event->button.time);
                        gnome_canvas_item_w2i (view_highlight->private->group,
@@ -2008,6 +1963,8 @@ p2_resize_event_handler (GnomeCanvasItem *handle_item,
 
        case GDK_MOTION_NOTIFY:
                if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+                       get_origin_and_corners (view_highlight,
+                                               &x0, &y0, &x1, &y1, &x2, &y2);
                        gnome_canvas_item_w2i (view_highlight->private->group,
                                               &event->button.x, &event->button.y);
                        /* x1 unchanged */
index a81aa8a957e175d6a213e618dfe6fdab51222a73..e0169fb0c1d5aee10bc249212c0a375be98f0c16 100644 (file)
@@ -113,7 +113,6 @@ gl_wdgt_bc_props_class_init (glWdgtBCPropsClass *class)
 static void
 gl_wdgt_bc_props_instance_init (glWdgtBCProps *prop)
 {
-       prop->scale_spin = NULL;
        prop->color_picker = NULL;
 }
 
@@ -157,29 +156,6 @@ gl_wdgt_bc_props_construct (glWdgtBCProps *prop)
 
        wvbox = GTK_WIDGET (prop);
 
-       /* ---- Scale line ---- */
-       whbox = gl_hig_hbox_new ();
-       gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox);
-
-       /* Scale Label */
-       prop->scale_label = gtk_label_new (_("Scale:"));
-       gtk_misc_set_alignment (GTK_MISC (prop->scale_label), 0, 0.5);
-       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->scale_label);
-
-       /* Scale widget */
-       adjust = gtk_adjustment_new (100.0, 50.0, 200.0, 10.0, 10.0, 10.0);
-       prop->scale_spin =
-           gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 10.0, 0);
-       g_signal_connect_swapped (G_OBJECT (prop->scale_spin), "changed",
-                                 G_CALLBACK (changed_cb),
-                                 G_OBJECT (prop));
-       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->scale_spin);
-
-       /* scale % Label */
-       wlabel = gtk_label_new (_("%"));
-       gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
-       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel);
-
        /* ---- Color line ---- */
        whbox = gl_hig_hbox_new ();
        gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox);
@@ -212,16 +188,10 @@ changed_cb (glWdgtBCProps *prop)
 /***************************************************************************/
 void
 gl_wdgt_bc_props_get_params (glWdgtBCProps *prop,
-                            gdouble       *scale,
                             guint         *color)
 {
        guint8 r, g, b, a;
 
-       /* ------- Get updated scale ------ */
-       *scale =
-           gtk_spin_button_get_value (GTK_SPIN_BUTTON(prop->scale_spin));
-       *scale /= 100.0;
-
        /* ------- Get updated line color ------ */
        gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (prop->color_picker),
                                   &r, &g, &b, &a);
@@ -234,12 +204,8 @@ gl_wdgt_bc_props_get_params (glWdgtBCProps *prop,
 /***************************************************************************/
 void
 gl_wdgt_bc_props_set_params (glWdgtBCProps *prop,
-                            gdouble        scale,
                             guint          color)
 {
-       scale *= 100.0;
-       gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop->scale_spin), scale);
-
        gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (prop->color_picker),
                                   GL_COLOR_I_RED (color),
                                   GL_COLOR_I_GREEN (color),
@@ -254,7 +220,6 @@ void
 gl_wdgt_bc_props_set_label_size_group (glWdgtBCProps   *prop,
                                       GtkSizeGroup    *label_size_group)
 {
-       gtk_size_group_add_widget (label_size_group, prop->scale_label);
        gtk_size_group_add_widget (label_size_group, prop->color_label);
 }
 
index dfa5b69b0cc4672ac2a5aa6624476331eb9e767a..fd588e313c61e2871a1822c3a718d27249a07d74 100644 (file)
@@ -45,9 +45,6 @@ typedef struct _glWdgtBCPropsClass glWdgtBCPropsClass;
 struct _glWdgtBCProps {
        glHigVBox  parent_widget;
 
-       GtkWidget *scale_label;
-       GtkWidget *scale_spin;
-
        GtkWidget *color_label;
        GtkWidget *color_picker;
 };
@@ -63,11 +60,9 @@ guint      gl_wdgt_bc_props_get_type       (void);
 GtkWidget *gl_wdgt_bc_props_new            (void);
 
 void       gl_wdgt_bc_props_get_params     (glWdgtBCProps *prop,
-                                           gdouble       *scale,
                                            guint         *color);
 
 void       gl_wdgt_bc_props_set_params     (glWdgtBCProps *prop,
-                                           gdouble        scale,
                                            guint          color);
 
 void       gl_wdgt_bc_props_set_label_size_group (glWdgtBCProps *prop,
index d19cbe040007288dc73361b545c59412d235127e..0f97455adf8153356caad55d3edb53c9592db661 100644 (file)
@@ -55,7 +55,9 @@ static void gl_wdgt_bc_style_instance_init (glWdgtBCStyle      *bc_style);
 static void gl_wdgt_bc_style_finalize      (GObject            *object);
 static void gl_wdgt_bc_style_construct     (glWdgtBCStyle      *bc_style);
 
-static void changed_cb                     (glWdgtBCStyle      *bc_style);
+static void style_changed_cb               (glWdgtBCStyle      *bc_style);
+static void checkbox_changed_cb            (glWdgtBCStyle      *bc_style);
+
 \f
 /****************************************************************************/
 /* Boilerplate Object stuff.                                                */
@@ -168,57 +170,80 @@ gl_wdgt_bc_style_construct (glWdgtBCStyle *bc_style)
 
        /* Style entry widget */
        wcombo = gtk_combo_new ();
-       style_list = NULL;
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_POSTNET));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_EAN));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_UPC));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_ISBN));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_39));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_128));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_128B));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_128C));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_I25));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_CBR));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_MSI));
-       style_list = g_list_append (style_list,
-                                   (gchar *)gl_barcode_style_to_text(GL_BARCODE_STYLE_PLS));
+       style_list = gl_barcode_get_styles_list ();;
        gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), style_list);
-       g_list_free (style_list);
+       gl_barcode_free_styles_list (style_list);
        bc_style->style_entry = GTK_COMBO (wcombo)->entry;
        gtk_entry_set_editable (GTK_ENTRY (bc_style->style_entry), FALSE);
        gtk_widget_set_size_request (wcombo, 200, -1);
-       g_signal_connect_swapped (G_OBJECT (bc_style->style_entry), "changed",
-                                 G_CALLBACK (changed_cb),
-                                 G_OBJECT (bc_style));
        gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo);
 
 
        /* Text checkbox widget */
        bc_style->text_check =
-           gtk_check_button_new_with_label (_("Show text with barcode"));
+           gtk_check_button_new_with_label (_("Text"));
        gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), bc_style->text_check);
+
+
+       /* Checksum checkbox widget */
+       bc_style->checksum_check =
+           gtk_check_button_new_with_label (_("Checksum"));
+       gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), bc_style->checksum_check);
+
+
+       /* Connect signal callbacks */
+       g_signal_connect_swapped (G_OBJECT (bc_style->style_entry), "changed",
+                                 G_CALLBACK (style_changed_cb),
+                                 G_OBJECT (bc_style));
        g_signal_connect_swapped (G_OBJECT (bc_style->text_check), "toggled",
-                                 G_CALLBACK (changed_cb),
+                                 G_CALLBACK (checkbox_changed_cb),
+                                 G_OBJECT (bc_style));
+       g_signal_connect_swapped (G_OBJECT (bc_style->checksum_check), "toggled",
+                                 G_CALLBACK (checkbox_changed_cb),
                                  G_OBJECT (bc_style));
+}
 
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Callback for when style has changed.                           */
+/*--------------------------------------------------------------------------*/
+static void
+style_changed_cb (glWdgtBCStyle *bc_style)
+{
+       gchar          *style_string;
+       glBarcodeStyle  style;
+
+       style_string =
+               gtk_editable_get_chars (GTK_EDITABLE(bc_style->style_entry),
+                                       0, -1);
+
+       /* Don't emit if entry is empty. */                                     
+       if ( *style_string != 0 ) {
+               style = gl_barcode_text_to_style (style_string);
+
+               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(bc_style->text_check),
+                                            gl_barcode_can_text (style));
+               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(bc_style->checksum_check),
+                                            gl_barcode_can_csum (style));
+
+               gtk_widget_set_sensitive (bc_style->text_check,
+                                         gl_barcode_text_optional (style));
+               gtk_widget_set_sensitive (bc_style->checksum_check,
+                                         gl_barcode_csum_optional (style));
+
+
+               /* Emit our "changed" signal */
+               g_signal_emit (G_OBJECT (bc_style),
+                              wdgt_bc_style_signals[CHANGED], 0);
+       }
+
+       g_free (style_string);
 }
 
 /*--------------------------------------------------------------------------*/
-/* PRIVATE.  Callback for when any control in the widget has changed.       */
+/* PRIVATE.  Callback for when either checkbox has changed.                 */
 /*--------------------------------------------------------------------------*/
 static void
-changed_cb (glWdgtBCStyle *bc_style)
+checkbox_changed_cb (glWdgtBCStyle *bc_style)
 {
        /* Emit our "changed" signal */
        g_signal_emit (G_OBJECT (bc_style),
@@ -231,7 +256,8 @@ changed_cb (glWdgtBCStyle *bc_style)
 void
 gl_wdgt_bc_style_get_params (glWdgtBCStyle  *bc_style,
                             glBarcodeStyle *style,
-                            gboolean       *text_flag)
+                            gboolean       *text_flag,
+                            gboolean       *checksum_flag)
 {
        gchar *style_string;
 
@@ -243,6 +269,9 @@ gl_wdgt_bc_style_get_params (glWdgtBCStyle  *bc_style,
        *text_flag =
            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bc_style->text_check));
 
+       *checksum_flag =
+           gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bc_style->checksum_check));
+
        g_free (style_string);
 }
 
@@ -252,7 +281,8 @@ gl_wdgt_bc_style_get_params (glWdgtBCStyle  *bc_style,
 void
 gl_wdgt_bc_style_set_params (glWdgtBCStyle  *bc_style,
                             glBarcodeStyle  style,
-                            gboolean        text_flag)
+                            gboolean        text_flag,
+                            gboolean        checksum_flag)
 {
        const gchar *style_string;
        gint         pos;
@@ -260,12 +290,12 @@ gl_wdgt_bc_style_set_params (glWdgtBCStyle  *bc_style,
        style_string = gl_barcode_style_to_text (style);
 
        g_signal_handlers_block_by_func (G_OBJECT(bc_style->style_entry),
-                                        G_CALLBACK (changed_cb),
+                                        G_CALLBACK (style_changed_cb),
                                         bc_style);
        gtk_editable_delete_text (GTK_EDITABLE (bc_style->style_entry),
                                  0, -1);
        g_signal_handlers_unblock_by_func (G_OBJECT(bc_style->style_entry),
-                                          G_CALLBACK(changed_cb),
+                                          G_CALLBACK(style_changed_cb),
                                           bc_style);
 
        pos = 0;
@@ -277,6 +307,9 @@ gl_wdgt_bc_style_set_params (glWdgtBCStyle  *bc_style,
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bc_style->text_check),
                                      text_flag);
 
+       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bc_style->checksum_check),
+                                     checksum_flag);
+
 }
 
 /****************************************************************************/
index 40d28f40a5aeba54c3411c592c07a71f875ef43b..d02f9074feba6568be031a960f73cab47110c4d8 100644 (file)
@@ -49,6 +49,7 @@ struct _glWdgtBCStyle {
        GtkWidget *style_entry;
 
        GtkWidget *text_check;
+       GtkWidget *checksum_check;
 };
 
 struct _glWdgtBCStyleClass {
@@ -63,11 +64,13 @@ GtkWidget *gl_wdgt_bc_style_new        (void);
 
 void       gl_wdgt_bc_style_get_params (glWdgtBCStyle  *bc_style,
                                        glBarcodeStyle *style,
-                                       gboolean       *text_flag);
+                                       gboolean       *text_flag,
+                                       gboolean       *checksum_flag);
 
 void       gl_wdgt_bc_style_set_params (glWdgtBCStyle  *bc_style,
                                        glBarcodeStyle  style,
-                                       gboolean        text_flag);
+                                       gboolean        text_flag,
+                                       gboolean        checksum_flag);
 
 void       gl_wdgt_bc_style_set_label_size_group (glWdgtBCStyle *bc_style,
                                                  GtkSizeGroup  *label_size_group);
index c1f05a7e9262f4f2696d1b797a8ad6db0b44ae99..c1445d79d26ea3244ddca2a6b8f33b9ff50d79a8 100644 (file)
@@ -664,8 +664,8 @@ xml_parse_barcode_props (xmlNodePtr  node,
        glTextNode         *text_node;
        glBarcodeStyle      style;
        gboolean            text_flag;
+       gboolean            checksum_flag;
        guint               color;
-       gdouble             scale;
 
        gl_debug (DEBUG_XML, "START");
 
@@ -678,8 +678,7 @@ xml_parse_barcode_props (xmlNodePtr  node,
        g_free (string);
 
        text_flag = gl_xml_get_prop_boolean (node, "text", FALSE);
-
-       scale = gl_xml_get_prop_double (node, "scale", 1.0);
+       checksum_flag = gl_xml_get_prop_boolean (node, "checksum", TRUE);
 
        text_node = g_new0 (glTextNode, 1);
        for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
@@ -696,7 +695,7 @@ xml_parse_barcode_props (xmlNodePtr  node,
 
        gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node);
        gl_label_barcode_set_props (GL_LABEL_BARCODE(object),
-                                   style, text_flag, color, scale);
+                                   style, text_flag, checksum_flag, color);
 
        gl_text_node_free (&text_node);
 
@@ -1184,8 +1183,8 @@ xml_create_barcode_props (xmlNodePtr     object_node,
        glTextNode          *text_node;
        glBarcodeStyle      style;
        gboolean            text_flag;
+       gboolean            checksum_flag;
        guint               color;
-       gdouble             scale;
        xmlNodePtr          child;
 
        gl_debug (DEBUG_XML, "START");
@@ -1194,13 +1193,13 @@ xml_create_barcode_props (xmlNodePtr     object_node,
 
        text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object));
        gl_label_barcode_get_props (GL_LABEL_BARCODE(object),
-                                   &style, &text_flag, &color, &scale);
+                                   &style, &text_flag, &checksum_flag, &color);
 
        gl_xml_set_prop_uint_hex (object_node, "color", color);
 
        xmlSetProp (object_node, "style", gl_barcode_style_to_text (style));
        gl_xml_set_prop_boolean (object_node, "text", text_flag);
-       gl_xml_set_prop_double (object_node, "scale", scale);
+       gl_xml_set_prop_boolean (object_node, "checksum", checksum_flag);
 
        if (text_node->field_flag) {
                child = xmlNewChild (object_node, ns, "Field", NULL);